python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.34k stars 449 forks source link

2.9.1: pytest is failing #802

Closed kloczek closed 2 years ago

kloczek commented 3 years ago

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

May I ask for help because few units are failing:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-babel-2.9.1-5.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-babel-2.9.1-5.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Using --randomly-seed=3035112980
rootdir: /home/tkloczko/rpmbuild/BUILD/babel-2.9.1, configfile: setup.cfg
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, trio-0.7.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1, twisted-1.13.3
collected 3136 items

tests/test_util.py .............                                                                                                                                     [  0%]
tests/messages/test_catalog.py ......................................                                                                                                [  1%]
tests/messages/test_mofile.py ....                                                                                                                                   [  1%]
tests/test_smoke.py ................................................................................................................................................ [  6%]
.................................................................................................................................................................... [ 11%]
.................................................................................................................................................................... [ 16%]
.................................................................................................................................................................... [ 22%]
.................................................................................................................................................................... [ 27%]
.................................................................................................................................................................... [ 32%]
.................................................................................................................................................................... [ 37%]
.................................................................................................................................................................... [ 42%]
.................................................................................................................................................................... [ 48%]
..........................................................................................................................                                           [ 52%]
tests/messages/test_plurals.py ..........                                                                                                                            [ 52%]
tests/messages/test_frontend.py .....FF...F......FFF.FFF............................                                                                                 [ 54%]
tests/test_date_intervals.py ........                                                                                                                                [ 54%]
tests/test_numbers.py ...............................................................................................................................                [ 58%]
tests/messages/test_extract.py ......................................                                                                                                [ 59%]
tests/messages/test_checkers.py ......                                                                                                                               [ 59%]
tests/messages/test_pofile.py ....................................................                                                                                   [ 61%]
tests/messages/test_js_extract.py ...........                                                                                                                        [ 61%]
tests/test_dates.py ............................s...............................................s................................................................... [ 66%]
.............................................................s...................................................................................................... [ 71%]
.....................................................................s............................................s................................................. [ 76%]
........................................................s.......................................................s.s................................................. [ 82%]
.............s...s.....s...............................................................s.................................................................s.......... [ 87%]
...................................s......................................................                                                                           [ 90%]
tests/messages/test_normalized_string.py .                                                                                                                           [ 90%]
tests/test_localedata.py ...........s.                                                                                                                               [ 90%]
tests/test_support.py ............s..s....ss........                                                                                                                 [ 91%]
tests/test_lists.py ..                                                                                                                                               [ 91%]
tests/test_day_periods.py .......                                                                                                                                    [ 91%]
tests/test_languages.py ..                                                                                                                                           [ 91%]
tests/test_core.py ............                                                                                                                                      [ 92%]
babel/plural.py .                                                                                                                                                    [ 92%]
tests/test_core.py ..                                                                                                                                                [ 92%]
babel/core.py ..                                                                                                                                                     [ 92%]
babel/numbers.py .                                                                                                                                                   [ 92%]
babel/support.py .                                                                                                                                                   [ 92%]
babel/core.py .                                                                                                                                                      [ 92%]
babel/numbers.py .                                                                                                                                                   [ 92%]
babel/util.py .                                                                                                                                                      [ 92%]
tests/test_core.py .                                                                                                                                                 [ 92%]
babel/dates.py .                                                                                                                                                     [ 92%]
babel/core.py .                                                                                                                                                      [ 92%]
babel/numbers.py .                                                                                                                                                   [ 92%]
babel/support.py .                                                                                                                                                   [ 92%]
babel/localedata.py .                                                                                                                                                [ 92%]
tests/test_core.py .                                                                                                                                                 [ 92%]
babel/dates.py ..                                                                                                                                                    [ 92%]
babel/core.py ..                                                                                                                                                     [ 92%]
tests/test_core.py .                                                                                                                                                 [ 92%]
babel/dates.py .                                                                                                                                                     [ 93%]
tests/test_core.py ...                                                                                                                                               [ 93%]
babel/dates.py .                                                                                                                                                     [ 93%]
babel/numbers.py .                                                                                                                                                   [ 93%]
babel/support.py .                                                                                                                                                   [ 93%]
tests/test_core.py .                                                                                                                                                 [ 93%]
babel/plural.py .                                                                                                                                                    [ 93%]
tests/test_core.py ..                                                                                                                                                [ 93%]
babel/messages/catalog.py ..                                                                                                                                         [ 93%]
babel/dates.py .                                                                                                                                                     [ 93%]
tests/test_core.py .                                                                                                                                                 [ 93%]
babel/numbers.py ..                                                                                                                                                  [ 93%]
babel/core.py .                                                                                                                                                      [ 93%]
babel/dates.py .                                                                                                                                                     [ 93%]
babel/numbers.py .                                                                                                                                                   [ 93%]
babel/core.py .                                                                                                                                                      [ 93%]
babel/units.py .                                                                                                                                                     [ 93%]
babel/core.py .                                                                                                                                                      [ 93%]
babel/dates.py .                                                                                                                                                     [ 93%]
babel/core.py .                                                                                                                                                      [ 93%]
babel/messages/frontend.py .                                                                                                                                         [ 93%]
babel/support.py .                                                                                                                                                   [ 93%]
tests/test_core.py .                                                                                                                                                 [ 93%]
babel/dates.py .                                                                                                                                                     [ 93%]
tests/test_core.py .                                                                                                                                                 [ 93%]
babel/messages/mofile.py .                                                                                                                                           [ 93%]
babel/numbers.py .                                                                                                                                                   [ 94%]
babel/messages/extract.py .                                                                                                                                          [ 94%]
babel/util.py .                                                                                                                                                      [ 94%]
babel/core.py ...                                                                                                                                                    [ 94%]
babel/messages/checkers.py .                                                                                                                                         [ 94%]
babel/core.py .                                                                                                                                                      [ 94%]
babel/support.py .                                                                                                                                                   [ 94%]
babel/core.py ...                                                                                                                                                    [ 94%]
babel/messages/catalog.py .                                                                                                                                          [ 94%]
babel/core.py ...                                                                                                                                                    [ 94%]
babel/dates.py .                                                                                                                                                     [ 94%]
tests/test_core.py ...                                                                                                                                               [ 94%]
babel/core.py .                                                                                                                                                      [ 94%]
tests/test_core.py .                                                                                                                                                 [ 94%]
babel/core.py .                                                                                                                                                      [ 94%]
babel/messages/catalog.py .                                                                                                                                          [ 94%]
babel/plural.py .                                                                                                                                                    [ 94%]
tests/test_core.py .                                                                                                                                                 [ 94%]
babel/messages/catalog.py .                                                                                                                                          [ 94%]
babel/messages/frontend.py .                                                                                                                                         [ 94%]
tests/test_core.py .                                                                                                                                                 [ 94%]
babel/messages/pofile.py .                                                                                                                                           [ 94%]
tests/test_core.py .                                                                                                                                                 [ 94%]
babel/core.py .                                                                                                                                                      [ 94%]
tests/test_core.py .                                                                                                                                                 [ 95%]
babel/units.py .                                                                                                                                                     [ 95%]
tests/test_core.py .                                                                                                                                                 [ 95%]
babel/core.py .                                                                                                                                                      [ 95%]
tests/test_core.py .                                                                                                                                                 [ 95%]
babel/units.py .                                                                                                                                                     [ 95%]
babel/plural.py .                                                                                                                                                    [ 95%]
babel/messages/pofile.py .                                                                                                                                           [ 95%]
babel/units.py .                                                                                                                                                     [ 95%]
babel/dates.py .                                                                                                                                                     [ 95%]
babel/numbers.py .                                                                                                                                                   [ 95%]
babel/messages/pofile.py .                                                                                                                                           [ 95%]
babel/dates.py .                                                                                                                                                     [ 95%]
babel/plural.py .                                                                                                                                                    [ 95%]
babel/core.py ...                                                                                                                                                    [ 95%]
tests/test_core.py .                                                                                                                                                 [ 95%]
babel/messages/plurals.py .                                                                                                                                          [ 95%]
babel/dates.py .                                                                                                                                                     [ 95%]
babel/lists.py .                                                                                                                                                     [ 95%]
babel/dates.py ..                                                                                                                                                    [ 95%]
babel/messages/catalog.py .                                                                                                                                          [ 95%]
tests/test_core.py .                                                                                                                                                 [ 95%]
babel/core.py .                                                                                                                                                      [ 95%]
babel/messages/pofile.py .                                                                                                                                           [ 95%]
babel/numbers.py .                                                                                                                                                   [ 95%]
babel/messages/extract.py .                                                                                                                                          [ 95%]
tests/test_core.py ..                                                                                                                                                [ 95%]
babel/core.py .                                                                                                                                                      [ 96%]
babel/plural.py .                                                                                                                                                    [ 96%]
babel/core.py ....                                                                                                                                                   [ 96%]
babel/plural.py .                                                                                                                                                    [ 96%]
tests/test_core.py .                                                                                                                                                 [ 96%]
babel/dates.py .                                                                                                                                                     [ 96%]
babel/units.py .                                                                                                                                                     [ 96%]
babel/support.py .                                                                                                                                                   [ 96%]
tests/test_core.py .                                                                                                                                                 [ 96%]
babel/numbers.py .                                                                                                                                                   [ 96%]
tests/test_core.py .                                                                                                                                                 [ 96%]
babel/numbers.py .                                                                                                                                                   [ 96%]
babel/dates.py ..                                                                                                                                                    [ 96%]
babel/core.py .                                                                                                                                                      [ 96%]
babel/messages/catalog.py .                                                                                                                                          [ 96%]
babel/dates.py .                                                                                                                                                     [ 96%]
tests/test_core.py ...                                                                                                                                               [ 96%]
babel/dates.py .                                                                                                                                                     [ 96%]
babel/core.py .                                                                                                                                                      [ 96%]
babel/dates.py .                                                                                                                                                     [ 96%]
babel/core.py ...                                                                                                                                                    [ 96%]
babel/dates.py .                                                                                                                                                     [ 96%]
tests/test_core.py .                                                                                                                                                 [ 96%]
babel/dates.py .                                                                                                                                                     [ 97%]
tests/test_core.py .                                                                                                                                                 [ 97%]
babel/support.py .                                                                                                                                                   [ 97%]
babel/numbers.py .                                                                                                                                                   [ 97%]
babel/core.py .                                                                                                                                                      [ 97%]
tests/test_core.py .                                                                                                                                                 [ 97%]
babel/core.py ..                                                                                                                                                     [ 97%]
babel/dates.py .                                                                                                                                                     [ 97%]
babel/numbers.py .                                                                                                                                                   [ 97%]
babel/core.py .                                                                                                                                                      [ 97%]
babel/support.py .                                                                                                                                                   [ 97%]
babel/messages/pofile.py .                                                                                                                                           [ 97%]
babel/core.py .                                                                                                                                                      [ 97%]
tests/test_core.py .                                                                                                                                                 [ 97%]
babel/support.py .                                                                                                                                                   [ 97%]
babel/messages/frontend.py .                                                                                                                                         [ 97%]
tests/test_core.py ..                                                                                                                                                [ 97%]
babel/core.py .                                                                                                                                                      [ 97%]
babel/numbers.py ..                                                                                                                                                  [ 97%]
babel/core.py .                                                                                                                                                      [ 97%]
babel/dates.py ..                                                                                                                                                    [ 97%]
tests/test_core.py .                                                                                                                                                 [ 97%]
babel/core.py .                                                                                                                                                      [ 97%]
babel/messages/catalog.py .                                                                                                                                          [ 97%]
tests/test_core.py .                                                                                                                                                 [ 97%]
babel/core.py .                                                                                                                                                      [ 97%]
babel/messages/catalog.py ..                                                                                                                                         [ 97%]
babel/numbers.py .                                                                                                                                                   [ 98%]
tests/test_core.py .                                                                                                                                                 [ 98%]
babel/localedata.py .                                                                                                                                                [ 98%]
babel/core.py .                                                                                                                                                      [ 98%]
tests/test_core.py .                                                                                                                                                 [ 98%]
babel/core.py .                                                                                                                                                      [ 98%]
babel/dates.py .                                                                                                                                                     [ 98%]
babel/messages/catalog.py .                                                                                                                                          [ 98%]
babel/messages/pofile.py .                                                                                                                                           [ 98%]
babel/plural.py .                                                                                                                                                    [ 98%]
babel/core.py ..                                                                                                                                                     [ 98%]
tests/messages/test_jslexer.py ......                                                                                                                                [ 98%]
tests/test_plural.py .............................................                                                                                                   [100%]

================================================================================= FAILURES =================================================================================
__________________________________________________________ CommandLineInterfaceTestCase.test_init_with_output_dir __________________________________________________________

self = <tests.messages.test_frontend.CommandLineInterfaceTestCase testMethod=test_init_with_output_dir>

        @freeze_time("1994-11-11")
        def test_init_with_output_dir(self):
            po_file = _po_file('en_US')
            self.cli.run(sys.argv + ['init',
                                     '--locale', 'en_US',
                                     '-d', os.path.join(i18n_dir),
                                     '-i', os.path.join(i18n_dir, 'messages.pot')])
            assert os.path.isfile(po_file)
            expected_content = r"""# English (United States) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: en_US\n"
    "Language-Team: en_US <LL@li.org>\n"
    "Plural-Forms: nplurals=2; plural=(n != 1)\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid "bar"
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""
    msgstr[1] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en')}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[532 chars]\n\n' != '# En[353 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[532 chars]\n\n'
E           Diff is 1080 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:1016: AssertionError
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO     babel:frontend.py:615 creating catalog /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/tests/messages/data/project/i18n/en_US/LC_MESSAGES/messages.po based on /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/tests/messages/data/project/i18n/messages.pot
_____________________________________________________ CommandLineInterfaceTestCase.test_init_more_than_2_plural_forms ______________________________________________________

self = <tests.messages.test_frontend.CommandLineInterfaceTestCase testMethod=test_init_more_than_2_plural_forms>

        @freeze_time("1994-11-11")
        def test_init_more_than_2_plural_forms(self):
            po_file = _po_file('lv_LV')
            self.cli.run(sys.argv + ['init',
                                     '--locale', 'lv_LV',
                                     '-d', i18n_dir,
                                     '-i', os.path.join(i18n_dir, 'messages.pot')])
            assert os.path.isfile(po_file)
            expected_content = r"""# Latvian (Latvia) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: lv_LV\n"
    "Language-Team: lv_LV <LL@li.org>\n"
    "Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
    " 2)\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid "bar"
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""
    msgstr[1] ""
    msgstr[2] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en')}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# La[346 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[585 chars]\n\n' != '# La[346 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[585 chars]\n\n'
E           Diff is 1128 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:1113: AssertionError
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO     babel:frontend.py:615 creating catalog /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/tests/messages/data/project/i18n/lv_LV/LC_MESSAGES/messages.po based on /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/tests/messages/data/project/i18n/messages.pot
_______________________________________________________ CommandLineInterfaceTestCase.test_init_singular_plural_forms _______________________________________________________

self = <tests.messages.test_frontend.CommandLineInterfaceTestCase testMethod=test_init_singular_plural_forms>

        @freeze_time("1994-11-11")
        def test_init_singular_plural_forms(self):
            po_file = _po_file('ja_JP')
            self.cli.run(sys.argv + ['init',
                                     '--locale', 'ja_JP',
                                     '-d', os.path.join(i18n_dir),
                                     '-i', os.path.join(i18n_dir, 'messages.pot')])
            assert os.path.isfile(po_file)
            expected_content = r"""# Japanese (Japan) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: ja_JP\n"
    "Language-Team: ja_JP <LL@li.org>\n"
    "Plural-Forms: nplurals=1; plural=0\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid "bar"
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en')}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# Ja[346 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[511 chars]\n\n' != '# Ja[346 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[511 chars]\n\n'
E           Diff is 1051 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:1063: AssertionError
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO     babel:frontend.py:615 creating catalog /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/tests/messages/data/project/i18n/ja_JP/LC_MESSAGES/messages.po based on /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/tests/messages/data/project/i18n/messages.pot
_________________________________________________________________ InitCatalogTestCase.test_supports_width __________________________________________________________________

self = <tests.messages.test_frontend.InitCatalogTestCase testMethod=test_supports_width>

        @freeze_time("1994-11-11")
        def test_supports_width(self):
            self.cmd.input_file = 'project/i18n/long_messages.pot'
            self.cmd.locale = 'en_US'
            self.cmd.output_dir = 'project/i18n'

            long_message = '"' + 'xxxxx ' * 15 + '"'

            with open('project/i18n/messages.pot', 'rb') as f:
                pot_contents = f.read().decode('latin-1')
            pot_with_very_long_line = pot_contents.replace('"bar"', long_message)
            with open(self.cmd.input_file, 'wb') as f:
                f.write(pot_with_very_long_line.encode('latin-1'))
            self.cmd.width = 120
            self.cmd.finalize_options()
            self.cmd.run()

            po_file = _po_file('en_US')
            assert os.path.isfile(po_file)
            expected_content = r"""# English (United States) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: en_US\n"
    "Language-Team: en_US <LL@li.org>\n"
    "Plural-Forms: nplurals=2; plural=(n != 1)\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid %(long_message)s
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""
    msgstr[1] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en_US'),
                'long_message': long_message}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[619 chars]\n\n' != '# En[353 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[619 chars]\n\n'
E           Diff is 1167 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:713: AssertionError
_____________________________________________________________ InitCatalogTestCase.test_keeps_catalog_non_fuzzy _____________________________________________________________

self = <tests.messages.test_frontend.InitCatalogTestCase testMethod=test_keeps_catalog_non_fuzzy>

        @freeze_time("1994-11-11")
        def test_keeps_catalog_non_fuzzy(self):
            self.cmd.input_file = 'project/i18n/messages_non_fuzzy.pot'
            self.cmd.locale = 'en_US'
            self.cmd.output_dir = 'project/i18n'

            self.cmd.finalize_options()
            self.cmd.run()

            po_file = _po_file('en_US')
            assert os.path.isfile(po_file)

            expected_content = r"""# English (United States) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: en_US\n"
    "Language-Team: en_US <LL@li.org>\n"
    "Plural-Forms: nplurals=2; plural=(n != 1)\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid "bar"
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""
    msgstr[1] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en')}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[532 chars]\n\n' != '# En[353 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[532 chars]\n\n'
E           Diff is 1080 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:487: AssertionError
_______________________________________________________ InitCatalogTestCase.test_correct_init_singular_plural_forms ________________________________________________________

self = <tests.messages.test_frontend.InitCatalogTestCase testMethod=test_correct_init_singular_plural_forms>

        @freeze_time("1994-11-11")
        def test_correct_init_singular_plural_forms(self):
            self.cmd.input_file = 'project/i18n/messages.pot'
            self.cmd.locale = 'ja_JP'
            self.cmd.output_dir = 'project/i18n'

            self.cmd.finalize_options()
            self.cmd.run()

            po_file = _po_file('ja_JP')
            assert os.path.isfile(po_file)

            expected_content = r"""# Japanese (Japan) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: ja_JP\n"
    "Language-Team: ja_JP <LL@li.org>\n"
    "Plural-Forms: nplurals=1; plural=0\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid "bar"
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='ja_JP')}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# Ja[346 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[511 chars]\n\n' != '# Ja[346 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[511 chars]\n\n'
E           Diff is 1051 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:592: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
WARNING: msg has more translations than num_plurals of catalog
WARNING: Problem on line 28: ''
_________________________________________________________________ InitCatalogTestCase.test_with_output_dir _________________________________________________________________

self = <tests.messages.test_frontend.InitCatalogTestCase testMethod=test_with_output_dir>

        @freeze_time("1994-11-11")
        def test_with_output_dir(self):
            self.cmd.input_file = 'project/i18n/messages.pot'
            self.cmd.locale = 'en_US'
            self.cmd.output_dir = 'project/i18n'

            self.cmd.finalize_options()
            self.cmd.run()

            po_file = _po_file('en_US')
            assert os.path.isfile(po_file)

            expected_content = r"""# English (United States) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: en_US\n"
    "Language-Team: en_US <LL@li.org>\n"
    "Plural-Forms: nplurals=2; plural=(n != 1)\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid "bar"
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""
    msgstr[1] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en')}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[532 chars]\n\n' != '# En[353 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[532 chars]\n\n'
E           Diff is 1080 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:435: AssertionError
________________________________________________________________ InitCatalogTestCase.test_supports_no_wrap _________________________________________________________________

self = <tests.messages.test_frontend.InitCatalogTestCase testMethod=test_supports_no_wrap>

        @freeze_time("1994-11-11")
        def test_supports_no_wrap(self):
            self.cmd.input_file = 'project/i18n/long_messages.pot'
            self.cmd.locale = 'en_US'
            self.cmd.output_dir = 'project/i18n'

            long_message = '"' + 'xxxxx ' * 15 + '"'

            with open('project/i18n/messages.pot', 'rb') as f:
                pot_contents = f.read().decode('latin-1')
            pot_with_very_long_line = pot_contents.replace('"bar"', long_message)
            with open(self.cmd.input_file, 'wb') as f:
                f.write(pot_with_very_long_line.encode('latin-1'))
            self.cmd.no_wrap = True

            self.cmd.finalize_options()
            self.cmd.run()

            po_file = _po_file('en_US')
            assert os.path.isfile(po_file)
            expected_content = r"""# English (United States) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: en_US\n"
    "Language-Team: en_US <LL@li.org>\n"
    "Plural-Forms: nplurals=2; plural=(n != 1)\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid %(long_message)s
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""
    msgstr[1] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en_US'),
                'long_message': long_message}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[619 chars]\n\n' != '# En[353 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[619 chars]\n\n'
E           Diff is 1167 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:653: AssertionError
________________________________________________________ InitCatalogTestCase.test_correct_init_more_than_2_plurals _________________________________________________________

self = <tests.messages.test_frontend.InitCatalogTestCase testMethod=test_correct_init_more_than_2_plurals>

        @freeze_time("1994-11-11")
        def test_correct_init_more_than_2_plurals(self):
            self.cmd.input_file = 'project/i18n/messages.pot'
            self.cmd.locale = 'lv_LV'
            self.cmd.output_dir = 'project/i18n'

            self.cmd.finalize_options()
            self.cmd.run()

            po_file = _po_file('lv_LV')
            assert os.path.isfile(po_file)

            expected_content = r"""# Latvian (Latvia) translations for TestProject.
    # Copyright (C) 2007 FooBar, Inc.
    # This file is distributed under the same license as the TestProject
    # project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, 2007.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: TestProject 0.1\n"
    "Report-Msgid-Bugs-To: bugs.address@email.tld\n"
    "POT-Creation-Date: 2007-04-01 15:30+0200\n"
    "PO-Revision-Date: %(date)s\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language: lv_LV\n"
    "Language-Team: lv_LV <LL@li.org>\n"
    "Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
    " 2)\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=utf-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: Babel %(version)s\n"

    #. This will be a translator coment,
    #. that will include several lines
    #: project/file1.py:8
    msgid "bar"
    msgstr ""

    #: project/file2.py:9
    msgid "foobar"
    msgid_plural "foobars"
    msgstr[0] ""
    msgstr[1] ""
    msgstr[2] ""

    """ % {'version': VERSION,
                'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
                                        tzinfo=LOCALTZ, locale='en')}
            with open(po_file, po_file_read_mode) as f:
                actual_content = f.read()
>           self.assertEqual(expected_content, actual_content)
E           AssertionError: '# La[346 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[585 chars]\n\n' != '# La[346 chars]-01 14:30+0200\\n"\n"PO-Revision-Date: 1994-11[585 chars]\n\n'
E           Diff is 1128 characters long. Set self.maxDiff to None to see it.

tests/messages/test_frontend.py:541: AssertionError
============================================================================= warnings summary =============================================================================
tests/test_numbers.py::test_format_number
tests/test_numbers.py::test_format_number
tests/test_support.py::test_format_number
babel/numbers.py::babel.numbers.format_number
babel/numbers.py::babel.numbers.format_number
babel/support.py::babel.support.Format.number
  /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/babel/numbers.py:352: DeprecationWarning: Use babel.numbers.format_decimal() instead.
    warnings.warn('Use babel.numbers.format_decimal() instead.', DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [14] tests/test_dates.py:39: zoneinfo not available
SKIPPED [1] tests/test_localedata.py:164: windows-only test
SKIPPED [1] tests/test_support.py:111: lgettext is deprecated
SKIPPED [1] tests/test_support.py:81: lgettext is deprecated
SKIPPED [1] tests/test_support.py:167: lgettext is deprecated
SKIPPED [1] tests/test_support.py:136: lgettext is deprecated
FAILED tests/messages/test_frontend.py::CommandLineInterfaceTestCase::test_init_with_output_dir - AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: ...
FAILED tests/messages/test_frontend.py::CommandLineInterfaceTestCase::test_init_more_than_2_plural_forms - AssertionError: '# La[346 chars]-01 15:30+0200\\n"\n"PO-Revisi...
FAILED tests/messages/test_frontend.py::CommandLineInterfaceTestCase::test_init_singular_plural_forms - AssertionError: '# Ja[346 chars]-01 15:30+0200\\n"\n"PO-Revision-...
FAILED tests/messages/test_frontend.py::InitCatalogTestCase::test_supports_width - AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[619 cha...
FAILED tests/messages/test_frontend.py::InitCatalogTestCase::test_keeps_catalog_non_fuzzy - AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-1...
FAILED tests/messages/test_frontend.py::InitCatalogTestCase::test_correct_init_singular_plural_forms - AssertionError: '# Ja[346 chars]-01 15:30+0200\\n"\n"PO-Revision-D...
FAILED tests/messages/test_frontend.py::InitCatalogTestCase::test_with_output_dir - AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[532 ch...
FAILED tests/messages/test_frontend.py::InitCatalogTestCase::test_supports_no_wrap - AssertionError: '# En[353 chars]-01 15:30+0200\\n"\n"PO-Revision-Date: 1994-11[619 c...
FAILED tests/messages/test_frontend.py::InitCatalogTestCase::test_correct_init_more_than_2_plurals - AssertionError: '# La[346 chars]-01 15:30+0200\\n"\n"PO-Revision-Dat...
========================================================= 9 failed, 3108 passed, 19 skipped, 6 warnings in 13.65s ==========================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
akx commented 2 years ago

Duplicate of #757 – before the root cause is fixed, set TZ=UTC when running tests.

kloczek commented 2 years ago

In pytest.ini is possible to force set any env variables. What about make new release (2.9.2?) πŸ˜„

Thank you

akx commented 2 years ago

Fixed by #701.

kloczek commented 2 years ago

Thank you πŸ˜„ Just tested that PR and looks like it fixes most odf the issues however one unis still is failing

================================================================================= FAILURES =================================================================================
_________________________________________________________________________ test_extract_error_code __________________________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fa5dee0a220>, capsys = <_pytest.capture.CaptureFixture object at 0x7fa5dee33c10>

    def test_extract_error_code(monkeypatch, capsys):
        monkeypatch.chdir(project_dir)
        cmdinst = configure_cli_command("compile --domain=messages --directory i18n --locale fi_BUGGY")
        assert cmdinst.run() == 1
        out, err = capsys.readouterr()
        # replace hack below for py2/py3 compatibility
>       assert "unknown named placeholder 'merkki'" in err.replace("u'", "'")
E       assert "unknown named placeholder 'merkki'" in ''
E        +  where '' = <built-in method replace of str object at 0x7fa5eac202f0>("u'", "'")
E        +    where <built-in method replace of str object at 0x7fa5eac202f0> = ''.replace

/home/tkloczko/rpmbuild/BUILD/babel-2.9.1/tests/messages/test_frontend.py:1394: AssertionError
============================================================================= warnings summary =============================================================================
babel/numbers.py::babel.numbers.format_number
babel/numbers.py::babel.numbers.format_number
babel/support.py::babel.support.Format.number
tests/test_numbers.py::test_format_number
tests/test_numbers.py::test_format_number
tests/test_support.py::test_format_number
  /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/babel/numbers.py:352: DeprecationWarning: Use babel.numbers.format_decimal() instead.
    warnings.warn('Use babel.numbers.format_decimal() instead.', DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [14] tests/test_dates.py:39: zoneinfo not available
SKIPPED [1] tests/test_localedata.py:164: windows-only test
SKIPPED [1] tests/test_support.py:167: lgettext is deprecated
SKIPPED [1] tests/test_support.py:136: lgettext is deprecated
SKIPPED [1] tests/test_support.py:111: lgettext is deprecated
SKIPPED [1] tests/test_support.py:81: lgettext is deprecated
FAILED tests/messages/test_frontend.py::test_extract_error_code - assert "unknown named placeholder 'merkki'" in ''
========================================================= 1 failed, 3116 passed, 19 skipped, 6 warnings in 11.96s ==========================================================
kloczek commented 2 years ago

And pytest shows onewarning

============================================================================= warnings summary =============================================================================
babel/numbers.py::babel.numbers.format_number
babel/numbers.py::babel.numbers.format_number
babel/support.py::babel.support.Format.number
tests/test_numbers.py::test_format_number
tests/test_numbers.py::test_format_number
tests/test_support.py::test_format_number
  /home/tkloczko/rpmbuild/BUILD/babel-2.9.1/babel/numbers.py:352: DeprecationWarning: Use babel.numbers.format_decimal() instead.
    warnings.warn('Use babel.numbers.format_decimal() instead.', DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
akx commented 2 years ago

Hi @kloczek – the warnings should be gone with the current master (4f8c7f67e4aa90790fbc36ce74220d22e2b00be7). Tests also seem to pass in CI, so I'm not quite sure why they'd fail for you.

kloczek commented 2 years ago

Cannot apply cleanly that commit on top of last release. Will retest that when will be available new release. Thank you.πŸ˜„