joke2k / faker

Faker is a Python package that generates fake data for you.
https://faker.readthedocs.io
MIT License
17.65k stars 1.92k forks source link

24.14.0: pytest fails in `tests/providers/test_job.py::TestCsCZ::test_job` unit #2033

Closed kloczek closed 5 months ago

kloczek commented 5 months ago

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-faker-24.14.0-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-faker-24.14.0-2.fc37.x86_64/usr/lib/python3.10/site-packages + /usr/bin/pytest -ra -m 'not network' -q ============================= test session starts ============================== platform linux -- Python 3.10.14, pytest-8.1.1, pluggy-1.4.0 rootdir: /home/tkloczko/rpmbuild/BUILD/faker-24.14.0 configfile: setup.cfg plugins: Faker-24.14.0 collected 1920 items tests/providers/__init__.py ............................................ [ 2%] . [ 2%] tests/providers/test_address.py ........................................ [ 4%] ...........................s............................................ [ 8%] ........................................................................ [ 11%] ........................................................................ [ 15%] ........................................................................ [ 19%] ............... [ 20%] tests/providers/test_automotive.py ..................................... [ 22%] ............................................ [ 24%] tests/providers/test_bank.py ........................................... [ 26%] ................................. [ 28%] tests/providers/test_barcode.py ........................................ [ 30%] ..... [ 30%] tests/providers/test_color.py .......................................... [ 32%] .. [ 33%] tests/providers/test_company.py ........................................ [ 35%] ............................. [ 36%] tests/providers/test_credit_card.py ....................... [ 37%] tests/providers/test_currency.py ....................................... [ 39%] [ 39%] tests/providers/test_date_time.py .....................s...............s [ 41%] ........................................................................ [ 45%] ... [ 45%] tests/providers/test_dynamic.py ....... [ 46%] tests/providers/test_emoji.py . [ 46%] tests/providers/test_enum.py ..... [ 46%] tests/providers/test_file.py .... [ 46%] tests/providers/test_geo.py .............................. [ 48%] tests/providers/test_internet.py ....................................... [ 50%] .................................... [ 52%] tests/providers/test_isbn.py ...... [ 52%] tests/providers/test_job.py .F............... [ 53%] tests/providers/test_lorem.py .......................................... [ 55%] ................................................. [ 58%] tests/providers/test_misc.py ..............s.......s.................... [ 60%] ..... [ 60%] tests/providers/test_person.py ......................................... [ 62%] ................................................ [ 65%] tests/providers/test_phone_number.py ................................... [ 66%] ....................... [ 68%] tests/providers/test_profile.py .. [ 68%] tests/providers/test_python.py ......................................... [ 70%] ................................................................ [ 73%] tests/providers/test_sbn.py .... [ 73%] tests/providers/test_ssn.py ............................................ [ 76%] ........................................................................ [ 80%] ...................... [ 81%] tests/providers/test_user_agent.py .... [ 81%] tests/pytest/session_overrides/session_locale/test_autouse_faker_locale.py s [ 81%] s [ 81%] tests/pytest/session_overrides/session_locale/test_autouse_faker_seed.py s [ 81%] s [ 81%] tests/pytest/session_overrides/session_locale/test_manual_injection.py s [ 81%] sss [ 81%] tests/pytest/test_autouse_faker_locale.py .. [ 81%] tests/pytest/test_autouse_faker_seed.py .. [ 81%] tests/pytest/test_manual_injection.py .... [ 82%] tests/pytest/test_unique_clear.py . [ 82%] tests/sphinx/test_docstring.py ............ [ 82%] tests/sphinx/test_validator.py ........... [ 83%] tests/test_decode.py ................................................... [ 86%] ........................................................................ [ 89%] ............ [ 90%] tests/test_factory.py ....................... [ 91%] tests/test_generator.py .................. [ 92%] tests/test_optional.py ..... [ 92%] tests/test_passport.py ...... [ 93%] tests/test_providers_formats.py ........................................ [ 95%] ................................................. [ 97%] tests/test_proxy.py ............................ [ 99%] tests/test_unique.py ..... [ 99%] tests/utils/test_utils.py ......... [100%] =================================== FAILURES =================================== ______________________________ TestCsCZ.test_job _______________________________ self = faker = , num_samples = 100 def test_job(self, faker, num_samples): for _ in range(num_samples): job = faker.job() assert isinstance(job, str) > assert job in CsCzJobProvider.jobs E AssertionError: assert 'Musician' in ('Administrátor, umění', 'Administrátor, státní služba', 'Advokát', 'Advokát pro ochranné známky', 'Akademický knihovník', 'Akupunkturista', ...) E + where ('Administrátor, umění', 'Administrátor, státní služba', 'Advokát', 'Advokát pro ochranné známky', 'Akademický knihovník', 'Akupunkturista', ...) = CsCzJobProvider.jobs tests/providers/test_job.py:35: AssertionError =============================== warnings summary =============================== ../../BUILDROOT/python-faker-24.14.0-2.fc37.x86_64/usr/lib/python3.10/site-packages/faker/providers/person/fr_QC/__init__.py:10 tests/test_providers_formats.py::test_no_invalid_formats[fr_QC] /home/tkloczko/rpmbuild/BUILDROOT/python-faker-24.14.0-2.fc37.x86_64/usr/lib/python3.10/site-packages/faker/providers/person/fr_QC/__init__.py:10: UserWarning: fr_QC locale is deprecated. Please use fr_CA. warnings.warn("fr_QC locale is deprecated. Please use fr_CA.") -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ SKIPPED [1] tests/providers/test_address.py:531: could not import 'ukpostcodeparser.parser': No module named 'ukpostcodeparser' SKIPPED [1] tests/providers/test_date_time.py:196: windows does not support sub second precision SKIPPED [1] tests/providers/test_date_time.py:558: windows does not support sub second precision SKIPPED [1] ../../../../../usr/lib/python3.10/site-packages/_pytest/unittest.py:357: requires the Python Image Library SKIPPED [1] ../../../../../usr/lib/python3.10/site-packages/_pytest/unittest.py:357: requires the Python xmltodict Library SKIPPED [2] tests/pytest/session_overrides/session_locale/test_autouse_faker_locale.py: This test is skipped by default since it depends on changes in the behavior of session-scoped fixtures. Use a separate pytest run for tests like this with the "--exclusive-faker-session" flag specified. SKIPPED [2] tests/pytest/session_overrides/session_locale/test_autouse_faker_seed.py: This test is skipped by default since it depends on changes in the behavior of session-scoped fixtures. Use a separate pytest run for tests like this with the "--exclusive-faker-session" flag specified. SKIPPED [4] tests/pytest/session_overrides/session_locale/test_manual_injection.py: This test is skipped by default since it depends on changes in the behavior of session-scoped fixtures. Use a separate pytest run for tests like this with the "--exclusive-faker-session" flag specified. FAILED tests/providers/test_job.py::TestCsCZ::test_job - AssertionError: asse... ====== 1 failed, 1906 passed, 13 skipped, 2 warnings in 67.92s (0:01:07) ======= /usr/lib/python3.10/site-packages/_pytest/pathlib.py:97: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-7ae409ac-eb39-4c09-9a2c-36c50e0683ad/test_safe_get_no_perms0 : [Errno 39] Directory not empty: 'test_safe_get_no_perms0' warnings.warn( /usr/lib/python3.10/site-packages/_pytest/pathlib.py:97: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-7ae409ac-eb39-4c09-9a2c-36c50e0683ad/test_safe_set_no_perms0 : [Errno 39] Directory not empty: 'test_safe_set_no_perms0' warnings.warn( /usr/lib/python3.10/site-packages/_pytest/pathlib.py:97: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-7ae409ac-eb39-4c09-9a2c-36c50e0683ad/test_safe_delete_no_perms0 : [Errno 39] Directory not empty: 'test_safe_delete_no_perms0' warnings.warn( /usr/lib/python3.10/site-packages/_pytest/pathlib.py:97: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-7ae409ac-eb39-4c09-9a2c-36c50e0683ad/test_rmtree_errorhandler_rerai0 : [Errno 39] Directory not empty: 'test_rmtree_errorhandler_rerai0' warnings.warn( /usr/lib/python3.10/site-packages/_pytest/pathlib.py:97: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-7ae409ac-eb39-4c09-9a2c-36c50e0683ad : [Errno 39] Directory not empty: '/tmp/pytest-of-tkloczko/garbage-7ae409ac-eb39-4c09-9a2c-36c50e0683ad' warnings.warn( ```
List of installed modules in build env: ```console Package Version ----------------------------- ----------- alabaster 0.7.16 Babel 2.14.0 build 1.2.1 charset-normalizer 3.3.2 docutils 0.20.1 exceptiongroup 1.1.3 freezegun 1.5.0 idna 3.7 imagesize 1.4.1 importlib_metadata 7.1.0 iniconfig 2.0.0 installer 0.7.0 Jinja2 3.1.3 MarkupSafe 2.1.5 packaging 24.0 pluggy 1.4.0 Pygments 2.17.2 pyproject_hooks 1.0.0 pytest 8.1.1 python-dateutil 2.9.0.post0 requests 2.31.0 setuptools 69.4.0 snowballstemmer 2.2.0 Sphinx 7.2.6 sphinxcontrib-applehelp 1.0.8 sphinxcontrib-devhelp 1.0.6 sphinxcontrib-htmlhelp 2.0.5 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.7 sphinxcontrib-serializinghtml 1.1.10 text-unidecode 1.3 tokenize_rt 5.2.0 tomli 2.0.1 urllib3 2.2.1 validators 0.28.1 wheel 0.43.0 zipp 3.18.1 ```

Please let me know if you need more details or want me to perform some diagnostics.

mtelka commented 5 months ago

The word 'Musician' is not in Czech language (CsCz), but in English. So apparently faker.job() returned wrong job (not a localized one).

mtelka commented 5 months ago

This seems to be already fixed: https://github.com/joke2k/faker/commit/7fa562bc4dbf56dbe3b6bf605b5e72b7f93fd571