0

I am using Visual Studio, python3.9 and pytest. I used to put __init__.py files in the project __tests__ folders that contained my unit test files. Then I encountered a failed unit test that was caused by the presence of an __init__.py file. The reason for the failure are in the links below. How do I get the test discovery tool (beaker symbol) in VScode to discover my unit tests without using __init__.py files?

pytest cannot import module while python can

pytest and why avoid init file

settings.json:

{
  "python.defaultInterpreterPath": "venv/bin/python",
  "python.testing.unittestArgs": [
    "-v",
    "-s",
    ".",
    "-p",
    "*tests.py"
  ],
  "python.testing.pytestEnabled": false,
  "python.testing.nosetestsEnabled": false,
  "python.testing.unittestEnabled": true,
  "python.linting.enabled": true,
  "python.linting.pycodestyleEnabled": true,
  "python.linting.pycodestyleArgs": [
    "--line-length",
    "120"
  ],
  "python.formatting.provider": "autopep8",
  "editor.formatOnPaste": false,
  "editor.formatOnSaveMode": "file",
  "python.formatting.autopep8Args": [
    "--max-line-length",
    "120"
  ],
  "git.ignoreLimitWarning": true,
}
DanGoodrick
  • 2,410
  • 5
  • 25
  • 48

0 Answers0