Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: don't present untestable base classes via pytest
pytest collects tests in classes that either derive from `unittest.TestCase` or are named with a `Test` prefix, where functions have a `test` prefix. More details on this logic are given at https://docs.pytest.org/en/7.4.x/explanation/goodpractices.html#test-discovery. pyftdi's `eeprom_mock` test has two base classes, `EepromMirrorTestCase` and `NonMirroredEepromTestCase`, that derive from `unittest.TestCase` and contain `test`-prefixed functions. These tests cannot be run from within the base classes, because they depend on a variable, `TEST_CONFIG_FILENAME`, which is expected to be set in their subclasses. The tests can only run from within the subclasses, and will produce an error result when attempting to run them from the base classes. To prevent pytest from collecting the untestable base class tests, the base classes are changed to not derive from `unittest.TestCase`, preferring instead to use multiple inheritance to allow the subclasses to derive from that class. This makes it possible to easily run the `eeprom_mock` test via pytest without spurious errors related to the untestable base classes.
- Loading branch information