-
Notifications
You must be signed in to change notification settings - Fork 872
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
When running pytest, there are a few classes that pytest thinks are test classes, but actually aren't. Most culprits are test-related types with Test in the name but not containing actual test methods. This leads to several pages of of warnings like the following:
# pytest
Users/gjcomer/src/executorch/backends/test/suite/reporting.py:152: PytestCollectionWarning: cannot collect test class 'TestCaseSummary' because it has a __init__ constructor (from: backends/test/suite/tests/test_reporting.py)
@dataclass
/Users/gjcomer/src/executorch/backends/test/suite/reporting.py:60: PytestCollectionWarning: cannot collect test class 'TestResult' because it has a __init__ constructor (from: backends/test/suite/tests/test_reporting.py)
class TestResult(IntEnum):
/Users/gjcomer/src/executorch/backends/test/suite/reporting.py:211: PytestCollectionWarning: cannot collect test class 'TestSessionState' because it has a __init__ constructor (from: backends/test/suite/tests/test_reporting.py)
@dataclass
/Users/gjcomer/src/executorch/src/executorch/backends/xnnpack/test/tester/tester.py:104: PytestCollectionWarning: cannot collect test class 'Tester' because it has a __init__ constructor (from: backends/xnnpack/test/fragments/test_dim_order.py)
class Tester(TesterBase):
/Users/gjcomer/src/executorch/src/executorch/backends/xnnpack/test/tester/tester.py:104: PytestCollectionWarning: cannot collect test class 'Tester' because it has a __init__ constructor (from: backends/xnnpack/test/ops/test_abs.py)
class Tester(TesterBase):
...
To solve this, we can do the following:
- Set up a conda or other Python environment (docs).
- Run
install_executorch.sh --editablefrom the root of the executorch source directory. - Run
pytestfrom the root of the executorch source directory. - For each non-test class generating a
PytestCollectionWarning, add__test__ = False(see https://stackoverflow.com/questions/58624641/how-to-prevent-pytestcollectionwarning-when-testing-class-testament-via-pytest).
To validate:
- Run
pytestagain. We shouldn't see anyPytestCollectionWarningswith relation to classes not containing tests.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers
Type
Projects
Status
No status