-
Notifications
You must be signed in to change notification settings - Fork 295
Closed
Labels
Priority:NormalNormal Priority Issue or PRNormal Priority Issue or PRbugSomething isn't workingSomething isn't working
Description
As originally reported by @dallan-keylogic:
Description
- It used to be possible to run pytest on a single test file by specifying the path to the test file as a command-line argument, e.g.:
pytest idaes/models/properties/modular_properties/eos/tests/test_enrtl.py - However, since recently, it seems this is not possible anymore: the same command runs all tests regardless of what file is specified
Probable cause
- Changes to
pytest.iniin Spring cleaning for dependencies, Pt. 2: The Tree-Chopping #1133 added a default command-line flag (--pyargs idaes) that specifies the location of theidaespackage as the testpath- This was done to ensure more consistent behavior regardless of e.g. the working directory where
pytestis invoked, as well as forcing the tests to be collected from the installed package (as opposed from the local directory, in case the two are not the same)
- This was done to ensure more consistent behavior regardless of e.g. the working directory where
- However, this cause the unwanted side effect of always adding all tests inside the
idaespackage directory (and subdirectories) to the current test run, effectively rendering the option of specifying individual test files or directories non-functional
Workarounds
- Edit
pytest.inilocally to remove the offending--pyargs idaesCLI flag - To select a subset of the tests to be run, use keywords through the
-kCLI option https://docs.pytest.org/en/7.2.x/reference/reference.html#command-line-flags instead of passing file paths as arguments- Note that this has an overhead since all tests still need to be collected first, which might take several seconds because of the size of the IDAES codebase and the amount of import-time metaprogramming
Remedies
- To reduce the possibility of these issues occurring in the future, we should consider carefully how the pytest configuration should be distributed between file(s), CLI flags, env vars, etc
Other useful info
- To show what tests would be run with the current configuration without actually running them, add
--collect-onlyto the pytest CLI options
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Priority:NormalNormal Priority Issue or PRNormal Priority Issue or PRbugSomething isn't workingSomething isn't working