question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Escape test ID`s in Testing API

See original GitHub issue

I have Python project with pytest’s tests and I catch this error

Error: Test IDs may not include the "<path-to-test>/tests/unit/interactions/mastercard/test_mastercard.py::TestMasterCardDeleteCard::test_generic_404_exception_is_not_affected[\u0000]" symbol
	at new D (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87)
	at Object.createTestItem (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:95)
	at vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9
	at vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9
	at Array.forEach (<anonymous>)
	at g (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at m (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9
	at Object.forEach (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87)
	at g (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at m (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9
	at Object.forEach (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87)
	at g (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at m (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9
	at Object.forEach (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87)
	at g (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at m (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9
	at Object.forEach (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87)
	at g (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at m (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9
	at Object.forEach (vscode-file://vscode-app/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:87)
	at g (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at Object.m [as updateTestItemFromRawData] (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:9)
	at _.resolveChildren (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:59)
	at _.refreshTestData (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:59)
	at processTicksAndRejections (internal/process/task_queues.js:93)
	at async v.refreshTestDataInternal (vscode-file://vscode-app/Users/perseus/.vscode/extensions/ms-python.python-2021.10.1336267007/out/client/extension.js:59)

Pytest allow to parametrize and test looks like this

    @pytest.mark.asyncio
    @pytest.mark.parametrize('body', ['', 'test', '{}', '{"test": true}', b'', b'\x00'])
    async def test_generic_404_exception_is_not_affected(

-> test_generic_404_exception_is_not_affected[\u0000] is valid test name

Screenshot 2021-10-20 at 11 48 18

Version: 1.61.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
karthiknadigcommented, Oct 20, 2021

We have plans on rewriting the test adapter. We should handle this case there.

/cc @kimadeline

1reaction
connor4312commented, Oct 20, 2021

NUL bytes are not allowed in test IDs, since we use it for delimiters internally

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-testing-library why use test id - Stack Overflow
Use a testid if you have to. I was wondering why this is a bad practice. I do not want to litter my...
Read more >
About Queries | Testing Library
Note that using this as an escape hatch to query by class or id is not recommended because they are invisible to the...
Read more >
How to Test your GraphQL Endpoints
Tutorial. How to Test your GraphQL Endpoints. Testing your API is critical to make sure that the business logic of your software is...
Read more >
Test Resource - Ghost Inspector
Testing resources for automated browser tests for your websites and web applications.
Read more >
Add getById method to render exports · Issue #183 - GitHub
Here's why a test id is better than class names it the id attribute: https://blog.kentcdodds.com/making-your-ui-tests-resilient-to-change-d37a6ee37269 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found