Skip to content

Clean up pytest warnings #18175

@GregoryComer

Description

@GregoryComer

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:

To validate:

  • Run pytest again. We shouldn't see any PytestCollectionWarnings with relation to classes not containing tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions