unittest_discovery evaluates __init__ methods #21044
Labels
area-testing
debt
Covers everything internal: CI, testing, refactoring of the codebase, etc.
documentation
Type: Bug
Behaviour
When unittest_discovery runs all class init methods are evaluated. I'm not sure how this can be remediated but it can result in difficult to troubleshoot situations.
I ran into this issue while looking into getting Selenium tests running in my Django application. The fix was to use a
@classmethod
setup method instead which is better practice but figuring out the problem was difficult. It was launching Firefox instances without a clear reason as to where it was spawning from:Expected vs. Actual
I am not sure what the solution to this could be. If you can avoid evaluating the
__init__
method that would solve the problem. If that isn't possible then the documentation should be updated to warn about this behaviour in test discovery:https://code.visualstudio.com/docs/python/testing#_test-discovery
Steps to reproduce:
I'll present the reproduction steps with the assumption that a Django application has been installed.
settings.json
at<project_root>/.vscode/settings.json
Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2023.6.0
VS Code version: Code 1.77.3 (Universal) (704ed70d4fd1c6bd6342c436f1ede30d1cff4710, 2023-04-12T09:19:37.325Z)
OS version: Darwin arm64 22.3.0
Modes:
Sandboxed: Yes
The text was updated successfully, but these errors were encountered: