{"id":29604599,"url":"https://github.com/bhrutledge/vscode-pytest-workspace","last_synced_at":"2026-07-03T22:33:27.311Z","repository":{"id":71236952,"uuid":"423679121","full_name":"bhrutledge/vscode-pytest-workspace","owner":"bhrutledge","description":"Trying to get pytest working in a deeply-nested Python project","archived":false,"fork":false,"pushed_at":"2021-11-02T02:18:16.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T00:38:44.523Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhrutledge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-11-02T02:14:54.000Z","updated_at":"2021-11-04T02:00:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"3499e754-b731-4a7d-b80a-513400d1c845","html_url":"https://github.com/bhrutledge/vscode-pytest-workspace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bhrutledge/vscode-pytest-workspace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fvscode-pytest-workspace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fvscode-pytest-workspace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fvscode-pytest-workspace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fvscode-pytest-workspace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhrutledge","download_url":"https://codeload.github.com/bhrutledge/vscode-pytest-workspace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhrutledge%2Fvscode-pytest-workspace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35104113,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-20T15:37:44.615Z","updated_at":"2026-07-03T22:33:27.270Z","avatar_url":"https://github.com/bhrutledge.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vscode-pytest-workspace\n\nTrying to get pytest working in a deeply-nested Python project.\n\nTests should only be discovered from `repo/rootdir/package`:\n\n```\n$ pwd\n/Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir\n\n$ pytest\n============================= test session starts ==============================\nplatform darwin -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0\nrootdir: /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir, configfile: pytest.ini, testpaths: package\ncollected 1 item\n\npackage/test_module.py .                                                 [100%]\n\n============================== 1 passed in 0.00s ===============================\n```\n\nSetting `--rootdir` to `${workspaceFolder}/repo/rootdir` (the parent directory of `pytest.ini`, matching [pytest's behavior](https://docs.pytest.org/en/stable/customize.html#initialization-determining-rootdir-and-configfile)) causes tests to be discovered from that directory, instead of `package`:\n\n```\n\u003e ~/Dev/vscode-pytest-workspace/venv/bin/python ~/.vscode-insiders/extensions/ms-python.python-2021.12.1409662628-dev/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear --rootdir ~/Dev/vscode-pytest-workspace/repo/rootdir ~/Dev/vscode-pytest-workspace/repo/rootdir\ncwd: ~/Dev/vscode-pytest-workspace/repo/rootdir\nError 2021-11-01 21:49:35: Error discovering pytest tests:\n [r [Error]: ============================= test session starts ==============================\nplatform darwin -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0\nrootdir: /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir, configfile: pytest.ini\ncollected 1 item / 1 error\n\n\u003cPackage package\u003e\n  \u003cModule test_module.py\u003e\n    \u003cFunction test_function\u003e\n\n==================================== ERRORS ====================================\n____________________ ERROR collecting scripts/test_error.py ____________________\nImportError while importing test module '/Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir/scripts/test_error.py'.\nHint: make sure your test modules/packages have valid Python names.\nTraceback:\n/opt/homebrew/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py:127: in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\nscripts/test_error.py:1: in \u003cmodule\u003e\n    import not_found\nE   ModuleNotFoundError: No module named 'not_found'\n=========================== short test summary info ============================\nERROR scripts/test_error.py\n!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!\n====================== 1 test collected, 1 error in 0.04s ======================\n\nTraceback (most recent call last):\n  File \"/Users/bhrutledge/.vscode-insiders/extensions/ms-python.python-2021.12.1409662628-dev/pythonFiles/testing_tools/run_adapter.py\", line 22, in \u003cmodule\u003e\n    main(tool, cmd, subargs, toolargs)\n  File \"/Users/bhrutledge/.vscode-insiders/extensions/ms-python.python-2021.12.1409662628-dev/pythonFiles/testing_tools/adapter/__main__.py\", line 100, in main\n    parents, result = run(toolargs, **subargs)\n  File \"/Users/bhrutledge/.vscode-insiders/extensions/ms-python.python-2021.12.1409662628-dev/pythonFiles/testing_tools/adapter/pytest/_discovery.py\", line 44, in discover\n    raise Exception(\"pytest discovery failed (exit code {})\".format(ec))\nException: pytest discovery failed (exit code 2)\n\n\tat ChildProcess.\u003canonymous\u003e (/Users/bhrutledge/.vscode-insiders/extensions/ms-python.python-2021.12.1409662628-dev/out/client/extension.js:17:38446)\n\tat Object.onceWrapper (events.js:422:26)\n\tat ChildProcess.emit (events.js:315:20)\n\tat maybeClose (internal/child_process.js:1048:16)\n\tat Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)]\n```\n\nTo avoid that error, I can add `--ignore scripts` to `pytestArgs`, which allows test discovery and running to succeed:\n\n```\n\u003e ~/Dev/vscode-pytest-workspace/venv/bin/python ~/.vscode-insiders/extensions/ms-python.python-2021.12.1409662628-dev/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear --rootdir ~/Dev/vscode-pytest-workspace/repo/rootdir --ignore scripts ~/Dev/vscode-pytest-workspace/repo/rootdir\ncwd: ~/Dev/vscode-pytest-workspace/repo/rootdir\n\n\u003e ~/Dev/vscode-pytest-workspace/venv/bin/python -m pytest --override-ini junit_family=xunit1 --junit-xml=/var/folders/bw/ttgk1hcs0k989q2yzmxkzn8c0000gp/T/tmp-65261jEOVCVjMxFJo.xml --rootdir ~/Dev/vscode-pytest-workspace/repo/rootdir --ignore scripts ./package/test_module.py::test_function\ncwd: ~/Dev/vscode-pytest-workspace/repo/rootdir\n\nRunning tests (pytest): /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir/package/test_module.py::test_function\nRunning test with arguments: --override-ini junit_family=xunit1 --junit-xml=/var/folders/bw/ttgk1hcs0k989q2yzmxkzn8c0000gp/T/tmp-65261jEOVCVjMxFJo.xml --rootdir /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir --ignore scripts ./package/test_module.py::test_function\nCurrent working directory: /Users/bhrutledge/Dev/vscode-pytest-workspace/repo/rootdir\nWorkspace directory: /Users/bhrutledge/Dev/vscode-pytest-workspace\nRun completed, parsing output\n./package/test_module.py::test_function Passed\n\nTotal number of tests expected to run: 1\nTotal number of tests run: 1\nTotal number of tests passed: 1\nTotal number of tests failed: 0\nTotal number of tests failed with errors: 0\nTotal number of tests skipped: 0\nTotal number of tests with no result data: 0\nFinished running tests!\n```\n\nHowever, given that `pytest` works from the command line (thanks to the `testpaths` option in `repo/rootdir/pytest.ini`), adding `--ignore` shouldn't be necessary.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhrutledge%2Fvscode-pytest-workspace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhrutledge%2Fvscode-pytest-workspace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhrutledge%2Fvscode-pytest-workspace/lists"}