Open kloczek opened 3 years ago
Thanks for this @kloczek, after running pytest --find-dependencies
I get the following result.
=====================================================
Run dependency analysis for 1750 tests.
Executed 5247 tests in 24 test runs.
Dependent tests:
tests/test_locales.py::TestLocaleValidation::test_locale_name_validation depends on tests/test_locales.py::TestCustomLocale::test_custom_locale_subclass
tests/test_locales.py::TestLocaleValidation::test_locale_validation depends on tests/test_locales.py::TestCustomLocale::test_custom_locale_subclass
=====================================================
Stated dependency.
class TestCustomLocale:
def test_custom_locale_subclass(self):
class CustomLocale1(locales.Locale):
names = ["foo", "foo-BAR"]
assert locales.get_locale("foo") is not None
assert locales.get_locale("foo-BAR") is not None
assert locales.get_locale("foo_bar") is not None
class CustomLocale2(locales.Locale):
names = ["underscores_ok"]
assert locales.get_locale("underscores_ok") is not None
Dependent tests
def test_locale_validation(self):
for locale_cls in self.locales.values():
# 7 days + 1 spacer to allow for 1-indexing of months
assert len(locale_cls.day_names) == 8
assert locale_cls.day_names[0] == ""
# ensure that all string from index 1 onward are valid (not blank or None)
assert all(locale_cls.day_names[1:])
assert len(locale_cls.day_abbreviations) == 8
assert locale_cls.day_abbreviations[0] == ""
assert all(locale_cls.day_abbreviations[1:])
# 12 months + 1 spacer to allow for 1-indexing of months
assert len(locale_cls.month_names) == 13
assert locale_cls.month_names[0] == ""
assert all(locale_cls.month_names[1:])
assert len(locale_cls.month_abbreviations) == 13
assert locale_cls.month_abbreviations[0] == ""
assert all(locale_cls.month_abbreviations[1:])
assert len(locale_cls.names) > 0
assert locale_cls.past is not None
assert locale_cls.future is not None
def test_locale_name_validation(self):
for locale_cls in self.locales.values():
for locale_name in locale_cls.names:
assert len(locale_name) == 2 or len(locale_name) == 5
assert locale_name.islower()
# Not a two-letter code
if len(locale_name) > 2:
assert "-" in locale_name
assert locale_name.count("-") == 1
System Info
Looks like pytest is failing when
pytest-randomly
is installed. Example:As long as randomly plugin is disaled everything is fine:
To diagnose that kind of issues https://github.com/mrbean-bremen/pytest-find-dependencies/ can be used.