Skip to content

Unable to run pytest on a single test file #1200

@lbianchi-lbl

Description

@lbianchi-lbl

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.ini in Spring cleaning for dependencies, Pt. 2: The Tree-Chopping #1133 added a default command-line flag (--pyargs idaes) that specifies the location of the idaes package as the testpath
    • This was done to ensure more consistent behavior regardless of e.g. the working directory where pytest is 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)
  • However, this cause the unwanted side effect of always adding all tests inside the idaes package directory (and subdirectories) to the current test run, effectively rendering the option of specifying individual test files or directories non-functional

Workarounds

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-only to the pytest CLI options

Metadata

Metadata

Assignees

Labels

Priority:NormalNormal Priority Issue or PRbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions