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

Failures with Python 3.9 #864

Closed
schidlo opened this issue Sep 11, 2020 · 6 comments
Closed

Failures with Python 3.9 #864

schidlo opened this issue Sep 11, 2020 · 6 comments

Comments

@schidlo
Copy link

schidlo commented Sep 11, 2020

In Fedora, we have the following failures with behave 1.2.6 and Python 3.9.0:

=================================== FAILURES ===================================
_ TestObjectToTextConversion.test_text__with_assert_failed_and_unicode_message[\xc4rgernis] _
self = <tests.unit.test_textutil.TestObjectToTextConversion object at 0xb6148df0>
message = 'Ärgernis'
    @pytest.mark.parametrize("message", [
        u"Ärgernis", u"Übermütig"
    ])
    def test_text__with_assert_failed_and_unicode_message(self, message):
        with pytest.raises(AssertionError) as e:
            assert False, message
    
        text2 = text(e)
        expected = u"AssertionError: %s" % message
>       assert text2.endswith(expected)
E       assert False
E        +  where False = <built-in method endswith of str object at 0xb5037f90>('AssertionError: Ärgernis')
E        +    where <built-in method endswith of str object at 0xb5037f90> = "<ExceptionInfo AssertionError('Ärgernis\\nassert False') tblen=1>".endswith
tests/unit/test_textutil.py:217: AssertionError
_ TestObjectToTextConversion.test_text__with_assert_failed_and_unicode_message[\xdcberm\xfctig] _
self = <tests.unit.test_textutil.TestObjectToTextConversion object at 0xb51c0e80>
message = 'Übermütig'
    @pytest.mark.parametrize("message", [
        u"Ärgernis", u"Übermütig"
    ])
    def test_text__with_assert_failed_and_unicode_message(self, message):
        with pytest.raises(AssertionError) as e:
            assert False, message
    
        text2 = text(e)
        expected = u"AssertionError: %s" % message
>       assert text2.endswith(expected)
E       assert False
E        +  where False = <built-in method endswith of str object at 0xb4fd0088>('AssertionError: Übermütig')
E        +    where <built-in method endswith of str object at 0xb4fd0088> = "<ExceptionInfo AssertionError('Übermütig\\nassert False') tblen=1>".endswith
tests/unit/test_textutil.py:217: AssertionError
_ TestObjectToTextConversion.test_text__with_raised_exception_and_unicode_message[AssertionError-\xc4rgernis] _
self = <tests.unit.test_textutil.TestObjectToTextConversion object at 0xb5814d30>
exception_class = <class 'AssertionError'>, message = 'Ärgernis'
    @pytest.mark.parametrize("exception_class, message", [
        (AssertionError, u"Ärgernis"),
        (RuntimeError, u"Übermütig"),
    ])
    def test_text__with_raised_exception_and_unicode_message(self,
                                                             exception_class,
                                                             message):
        with pytest.raises(exception_class) as e:
            raise exception_class(message)
    
        text2 = text(e)
        expected = u"%s: %s" % (exception_class.__name__, message)
        assert isinstance(text2, six.text_type)
>       assert text2.endswith(expected)
E       assert False
E        +  where False = <built-in method endswith of str object at 0xb52e2f98>('AssertionError: Ärgernis')
E        +    where <built-in method endswith of str object at 0xb52e2f98> = "<ExceptionInfo AssertionError('Ärgernis') tblen=1>".endswith
tests/unit/test_textutil.py:246: AssertionError
_ TestObjectToTextConversion.test_text__with_raised_exception_and_unicode_message[RuntimeError-\xdcberm\xfctig] _
self = <tests.unit.test_textutil.TestObjectToTextConversion object at 0xb506cb50>
exception_class = <class 'RuntimeError'>, message = 'Übermütig'
    @pytest.mark.parametrize("exception_class, message", [
        (AssertionError, u"Ärgernis"),
        (RuntimeError, u"Übermütig"),
    ])
    def test_text__with_raised_exception_and_unicode_message(self,
                                                             exception_class,
                                                             message):
        with pytest.raises(exception_class) as e:
            raise exception_class(message)
    
        text2 = text(e)
        expected = u"%s: %s" % (exception_class.__name__, message)
        assert isinstance(text2, six.text_type)
>       assert text2.endswith(expected)
E       assert False
E        +  where False = <built-in method endswith of str object at 0xb503b0d0>('RuntimeError: Übermütig')
E        +    where <built-in method endswith of str object at 0xb503b0d0> = "<ExceptionInfo RuntimeError('Übermütig') tblen=1>".endswith
tests/unit/test_textutil.py:246: AssertionError
@schidlo
Copy link
Author

schidlo commented Sep 11, 2020

Full build.log: build.log

@jenisys
Copy link
Member

jenisys commented Sep 22, 2020

This test covers corner cases related to unicode and unicode encoding problems.
Therefore, it would be helpful to get a dump of your environment variables that are related to the local settings, like:

# -- SEE: man locale => LANG, LC_*
$ env | grep UTF
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8

@schidlo
Copy link
Author

schidlo commented Sep 24, 2020

I have tried with LANG=en_US.UTF-8 and cs_CZ.UTF-8 and both failed in the same tests.

One run with:
LC_MONETARY=cs_CZ.UTF-8
LANG=cs_CZ.UTF-8
LC_PAPER=cs_CZ.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_NUMERIC=cs_CZ.UTF-8

Second just with LANG=en_US.UTF-8

@schidlo
Copy link
Author

schidlo commented Sep 24, 2020

The problem seems to be that pytest version changed from 4.6.11 to 6.0.2.

There was change in version 5.0.0 in what repr of pytest's ExceptionInfo returns. here is the issue

With pytest 4.6.11:
str(e) (same as text(e)):
'/home/pschindl/src/upstream/forks/behave/tests/unit/test_textutil.py:216: AssertionError: Ärgernis'
repr(e):
''

With pytest 6.0.2:
str(e) == text(e) == repr(e):
"<ExceptionInfo AssertionError('Ärgernis\nassert False') tblen=1>"
e.value.args[0]:
'Ärgernis\nassert False'

I'm not sure, what the tests should check exactly, but could it be check like this?

assert e.type == AssertionError
assert e.match(message)

@schidlo
Copy link
Author

schidlo commented Sep 24, 2020

Aaaaaand if I didn't check my old fork I would realise that it is already fixed in master :) So I will just create patch for that two tests. With master it works correctly.

@schidlo schidlo closed this as completed Sep 24, 2020
@jenisys
Copy link
Member

jenisys commented Sep 24, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants