Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New code highlighting tests fail on Mageia 8 buildsystem #6938

Open
akien-mga opened this issue Mar 18, 2020 · 1 comment
Open

New code highlighting tests fail on Mageia 8 buildsystem #6938

akien-mga opened this issue Mar 18, 2020 · 1 comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: regression indicates a problem that was introduced in a release which was working previously

Comments

@akien-mga
Copy link

akien-mga commented Mar 18, 2020

Tests from pytest 5.4.1 fail on Mageia Cauldron's buildsystem with python 3.8.2.
It seems related to the changes in #6658 as a local revert of that PR makes the test_terminal.py pass again (and other failures are from that PR's new tests).

=================================== FAILURES ===================================
_______________________ test_code_highlight[with markup] _______________________

has_markup = True, expected = '{kw}assert{hl-reset} {number}0{hl-reset}\n'
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>

    @pytest.mark.parametrize(
        "has_markup, expected",
        [
            pytest.param(
                True, "{kw}assert{hl-reset} {number}0{hl-reset}\n", id="with markup"
            ),
            pytest.param(False, "assert 0\n", id="no markup"),
        ],
    )
    def test_code_highlight(has_markup, expected, color_mapping):
        f = StringIO()
        tw = TerminalWriter(f)
        tw.hasmarkup = has_markup
        tw._write_source(["assert 0"])
>       assert f.getvalue().splitlines(keepends=True) == color_mapping.format([expected])
E       AssertionError: assert ['assert 0\n'] == ['\x1b[94mass...[39;49;00m\n']
E         At index 0 diff: 'assert 0\n' != '\x1b[94massert\x1b[39;49;00m \x1b[94m0\x1b[39;49;00m\n'
E         Use -v to get the full diff

testing/code/test_terminal_writer.py:22: AssertionError
________________________________ test_color_yes ________________________________

testdir = <Testdir local('/tmp/pytest-of-iurt/pytest-0/test_color_yes0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>

    def test_color_yes(testdir, color_mapping):
        p1 = testdir.makepyfile(
            """
            def fail():
                assert 0
    
            def test_this():
                fail()
            """
        )
        result = testdir.runpytest("--color=yes", str(p1))
        color_mapping.requires_ordered_markup(result)
>       result.stdout.fnmatch_lines(
            color_mapping.format_for_fnmatch(
                [
                    "{bold}=*= test session starts =*={reset}",
                    "collected 1 item",
                    "",
                    "test_color_yes.py {red}F{reset}{red} * [100%]{reset}",
                    "",
                    "=*= FAILURES =*=",
                    "{red}{bold}_*_ test_this _*_{reset}",
                    "",
                    "    {kw}def{hl-reset} {function}test_this{hl-reset}():",
                    ">       fail()",
                    "",
                    "{bold}{red}test_color_yes.py{reset}:5: ",
                    "_ _ * _ _*",
                    "",
                    "    {kw}def{hl-reset} {function}fail{hl-reset}():",
                    ">       {kw}assert{hl-reset} {number}0{hl-reset}",
                    "{bold}{red}E       assert 0{reset}",
                    "",
                    "{bold}{red}test_color_yes.py{reset}:2: AssertionError",
                    "{red}=*= {red}{bold}1 failed{reset}{red} in *s{reset}{red} =*={reset}",
                ]
            )
        )
E       Failed: fnmatch: '\x1b[[]1m=*= test session starts =*=\x1b[[]0m'
E          with: '\x1b[1m============================= test session starts ==============================\x1b[0m'
E       nomatch: 'collected 1 item'
E           and: 'platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1'
E           and: 'rootdir: /tmp/pytest-of-iurt/pytest-0/test_color_yes0'
E       exact match: 'collected 1 item'
E       exact match: ''
E       fnmatch: 'test_color_yes.py \x1b[[]31mF\x1b[[]0m\x1b[[]31m * [[]100%]\x1b[[]0m'
E          with: 'test_color_yes.py \x1b[31mF\x1b[0m\x1b[31m                                                      [100%]\x1b[0m'
E       exact match: ''
E       fnmatch: '=*= FAILURES =*='
E          with: '=================================== FAILURES ==================================='
E       fnmatch: '\x1b[[]31m\x1b[[]1m_*_ test_this _*_\x1b[[]0m'
E          with: '\x1b[31m\x1b[1m__________________________________ test_this ___________________________________\x1b[0m'
E       exact match: ''
E       nomatch: '    \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_this\x1b[[]39;49;00m():'
E           and: '    def test_this():'
E           and: '>       fail()'
E           and: ''
E           and: '\x1b[1m\x1b[31mtest_color_yes.py\x1b[0m:5: '
E           and: '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ '
E           and: ''
E           and: '    def fail():'
E           and: '>       assert 0'
E           and: '\x1b[1m\x1b[31mE       assert 0\x1b[0m'
E           and: ''
E           and: '\x1b[1m\x1b[31mtest_color_yes.py\x1b[0m:2: AssertionError'
E           and: '=========================== short test summary info ============================'
E           and: 'FAILED test_color_yes.py::test_this - assert 0'
E           and: '\x1b[31m============================== \x1b[31m\x1b[1m1 failed\x1b[0m\x1b[31m in 0.01s\x1b[0m\x1b[31m ===============================\x1b[0m'
E       remains unmatched: '    \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_this\x1b[[]39;49;00m():'

/home/iurt/rpmbuild/BUILD/pytest-5.4.1/testing/test_terminal.py:925: Failed
----------------------------- Captured stdout call -----------------------------
�[1m============================= test session starts ==============================�[0m
platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /tmp/pytest-of-iurt/pytest-0/test_color_yes0
collected 1 item

test_color_yes.py �[31mF�[0m�[31m                                                      [100%]�[0m

=================================== FAILURES ===================================
�[31m�[1m__________________________________ test_this ___________________________________�[0m

    def test_this():
>       fail()

�[1m�[31mtest_color_yes.py�[0m:5: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def fail():
>       assert 0
�[1m�[31mE       assert 0�[0m

�[1m�[31mtest_color_yes.py�[0m:2: AssertionError
=========================== short test summary info ============================
FAILED test_color_yes.py::test_this - assert 0
�[31m============================== �[31m�[1m1 failed�[0m�[31m in 0.01s�[0m�[31m ===============================�[0m
_________________ TestCodeHighlight.test_code_highlight_simple _________________

self = <test_terminal.TestCodeHighlight object at 0xf0c66f70>
testdir = <Testdir local('/tmp/pytest-of-iurt/pytest-0/test_code_highlight_simple0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>

    def test_code_highlight_simple(self, testdir: Testdir, color_mapping) -> None:
        testdir.makepyfile(
            """
            def test_foo():
                assert 1 == 10
        """
        )
        result = testdir.runpytest("--color=yes")
        color_mapping.requires_ordered_markup(result)
>       result.stdout.fnmatch_lines(
            color_mapping.format_for_fnmatch(
                [
                    "    {kw}def{hl-reset} {function}test_foo{hl-reset}():",
                    ">       {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}",
                    "{bold}{red}E       assert 1 == 10{reset}",
                ]
            )
        )
E       Failed: nomatch: '    \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
E           and: '\x1b[1m============================= test session starts ==============================\x1b[0m'
E           and: 'platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1'
E           and: 'rootdir: /tmp/pytest-of-iurt/pytest-0/test_code_highlight_simple0'
E           and: 'collected 1 item'
E           and: ''
E           and: 'test_code_highlight_simple.py \x1b[31mF\x1b[0m\x1b[31m                                          [100%]\x1b[0m'
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '\x1b[31m\x1b[1m___________________________________ test_foo ___________________________________\x1b[0m'
E           and: ''
E           and: '    def test_foo():'
E           and: '>       assert 1 == 10'
E           and: '\x1b[1m\x1b[31mE       assert 1 == 10\x1b[0m'
E           and: ''
E           and: '\x1b[1m\x1b[31mtest_code_highlight_simple.py\x1b[0m:2: AssertionError'
E           and: '=========================== short test summary info ============================'
E           and: 'FAILED test_code_highlight_simple.py::test_foo - assert 1 == 10'
E           and: '\x1b[31m============================== \x1b[31m\x1b[1m1 failed\x1b[0m\x1b[31m in 0.01s\x1b[0m\x1b[31m ===============================\x1b[0m'
E       remains unmatched: '    \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'

/home/iurt/rpmbuild/BUILD/pytest-5.4.1/testing/test_terminal.py:2110: Failed
----------------------------- Captured stdout call -----------------------------
�[1m============================= test session starts ==============================�[0m
platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /tmp/pytest-of-iurt/pytest-0/test_code_highlight_simple0
collected 1 item

test_code_highlight_simple.py �[31mF�[0m�[31m                                          [100%]�[0m

=================================== FAILURES ===================================
�[31m�[1m___________________________________ test_foo ___________________________________�[0m

    def test_foo():
>       assert 1 == 10
�[1m�[31mE       assert 1 == 10�[0m

�[1m�[31mtest_code_highlight_simple.py�[0m:2: AssertionError
=========================== short test summary info ============================
FAILED test_code_highlight_simple.py::test_foo - assert 1 == 10
�[31m============================== �[31m�[1m1 failed�[0m�[31m in 0.01s�[0m�[31m ===============================�[0m
______________ TestCodeHighlight.test_code_highlight_continuation ______________

self = <test_terminal.TestCodeHighlight object at 0xf3809988>
testdir = <Testdir local('/tmp/pytest-of-iurt/pytest-0/test_code_highlight_continuation0')>
color_mapping = <class 'conftest.color_mapping.<locals>.ColorMapping'>

    def test_code_highlight_continuation(self, testdir: Testdir, color_mapping) -> None:
        testdir.makepyfile(
            """
            def test_foo():
                print('''
                '''); assert 0
        """
        )
        result = testdir.runpytest("--color=yes")
        color_mapping.requires_ordered_markup(result)
    
>       result.stdout.fnmatch_lines(
            color_mapping.format_for_fnmatch(
                [
                    "    {kw}def{hl-reset} {function}test_foo{hl-reset}():",
                    "        {print}print{hl-reset}({str}'''{hl-reset}{str}{hl-reset}",
                    ">   {str}    {hl-reset}{str}'''{hl-reset}); {kw}assert{hl-reset} {number}0{hl-reset}",
                    "{bold}{red}E       assert 0{reset}",
                ]
            )
        )
E       Failed: nomatch: '    \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'
E           and: '\x1b[1m============================= test session starts ==============================\x1b[0m'
E           and: 'platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1'
E           and: 'rootdir: /tmp/pytest-of-iurt/pytest-0/test_code_highlight_continuation0'
E           and: 'collected 1 item'
E           and: ''
E           and: 'test_code_highlight_continuation.py \x1b[31mF\x1b[0m\x1b[31m                                    [100%]\x1b[0m'
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '\x1b[31m\x1b[1m___________________________________ test_foo ___________________________________\x1b[0m'
E           and: ''
E           and: '    def test_foo():'
E           and: "        print('''"
E           and: ">       '''); assert 0"
E           and: '\x1b[1m\x1b[31mE       assert 0\x1b[0m'
E           and: ''
E           and: '\x1b[1m\x1b[31mtest_code_highlight_continuation.py\x1b[0m:3: AssertionError'
E           and: '----------------------------- Captured stdout call -----------------------------'
E           and: ''
E           and: '    '
E           and: '=========================== short test summary info ============================'
E           and: 'FAILED test_code_highlight_continuation.py::test_foo - assert 0'
E           and: '\x1b[31m============================== \x1b[31m\x1b[1m1 failed\x1b[0m\x1b[31m in 0.01s\x1b[0m\x1b[31m ===============================\x1b[0m'
E       remains unmatched: '    \x1b[[]94mdef\x1b[[]39;49;00m \x1b[[]92mtest_foo\x1b[[]39;49;00m():'

/home/iurt/rpmbuild/BUILD/pytest-5.4.1/testing/test_terminal.py:2131: Failed
----------------------------- Captured stdout call -----------------------------
�[1m============================= test session starts ==============================�[0m
platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /tmp/pytest-of-iurt/pytest-0/test_code_highlight_continuation0
collected 1 item

test_code_highlight_continuation.py �[31mF�[0m�[31m                                    [100%]�[0m

=================================== FAILURES ===================================
�[31m�[1m___________________________________ test_foo ___________________________________�[0m

    def test_foo():
        print('''
>       '''); assert 0
�[1m�[31mE       assert 0�[0m

�[1m�[31mtest_code_highlight_continuation.py�[0m:3: AssertionError
----------------------------- Captured stdout call -----------------------------

    
=========================== short test summary info ============================
FAILED test_code_highlight_continuation.py::test_foo - assert 0
�[31m============================== �[31m�[1m1 failed�[0m�[31m in 0.01s�[0m�[31m ===============================�[0m

I'm not one of the Mageia sysadmins but I suppose that the buildsystem's terminal may not be configured to support color codes necessary for these tests.
In case it's relevant, it also uses C as locale.

Full build log:
build.0.20200318084502.log
Build environment (rpm -qa -- nothing installed via pip):
rpm_qa.0.20200318084502.log
RPM spec file: http://svnweb.mageia.org/packages/cauldron/python-pytest/current/SPECS/python-pytest.spec?revision=1557638&view=markup&pathrev=1557638

Update: Successful build log when PR #6658 is reverted with this patch: build.0.20200318104521.log
(Of course I'm not asking for it to be reverted, this is just a temporary hack to get things to build on our end.)

@Zac-HD Zac-HD added topic: reporting related to terminal output and user-facing messages and errors type: regression indicates a problem that was introduced in a release which was working previously labels Mar 18, 2020
@blueyed blueyed closed this as completed Mar 27, 2020
@blueyed blueyed reopened this Mar 27, 2020
@blueyed
Copy link
Contributor

blueyed commented Mar 27, 2020

Tests should be skipped without pygments (I've done this in my fork, in case somebody wants to pick it from there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: regression indicates a problem that was introduced in a release which was working previously
Projects
None yet
Development

No branches or pull requests

3 participants