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

test_annotations fails on PyPy3 #509

Open
hynek opened this issue Feb 25, 2019 · 5 comments

Comments

Projects
None yet
4 participants
@hynek
Copy link
Member

commented Feb 25, 2019

It looks like the fixtures don't reach the class bodies? So this could be either on pytest or pypy I guess.

========================================================================== FAILURES ==========================================================================
_______________________________________________ TestAnnotations.test_annotations_strings[typing.ClassVar-True] _______________________________________________

self = <tests.test_annotations.TestAnnotations object at 0x0000000112e29d38>, slots = True, classvar = 'typing.ClassVar'

    @pytest.mark.parametrize("slots", [True, False])
    @pytest.mark.parametrize("classvar", _classvar_prefixes)
    def test_annotations_strings(self, slots, classvar):
        """
        String annotations are passed into __init__ as is.
        """

>       @attr.s(auto_attribs=True, slots=slots)
        class C:

tests/test_annotations.py:215:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @attr.s(auto_attribs=True, slots=slots)
    class C:
>       cls_var: classvar + "[int]" = 23
E       NameError: name 'classvar' is not defined

tests/test_annotations.py:217: NameError
______________________________________________ TestAnnotations.test_annotations_strings[typing.ClassVar-False] _______________________________________________

self = <tests.test_annotations.TestAnnotations object at 0x0000000113662f00>, slots = False, classvar = 'typing.ClassVar'

    @pytest.mark.parametrize("slots", [True, False])
    @pytest.mark.parametrize("classvar", _classvar_prefixes)
    def test_annotations_strings(self, slots, classvar):
        """
        String annotations are passed into __init__ as is.
        """

>       @attr.s(auto_attribs=True, slots=slots)
        class C:

tests/test_annotations.py:215:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @attr.s(auto_attribs=True, slots=slots)
    class C:
>       cls_var: classvar + "[int]" = 23
E       NameError: name 'classvar' is not defined

tests/test_annotations.py:217: NameError
_________________________________________________ TestAnnotations.test_annotations_strings[t.ClassVar-True] __________________________________________________

self = <tests.test_annotations.TestAnnotations object at 0x000000011344b280>, slots = True, classvar = 't.ClassVar'

    @pytest.mark.parametrize("slots", [True, False])
    @pytest.mark.parametrize("classvar", _classvar_prefixes)
    def test_annotations_strings(self, slots, classvar):
        """
        String annotations are passed into __init__ as is.
        """

>       @attr.s(auto_attribs=True, slots=slots)
        class C:

tests/test_annotations.py:215:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @attr.s(auto_attribs=True, slots=slots)
    class C:
>       cls_var: classvar + "[int]" = 23
E       NameError: name 'classvar' is not defined

tests/test_annotations.py:217: NameError
_________________________________________________ TestAnnotations.test_annotations_strings[t.ClassVar-False] _________________________________________________

self = <tests.test_annotations.TestAnnotations object at 0x0000000114ae31a0>, slots = False, classvar = 't.ClassVar'

    @pytest.mark.parametrize("slots", [True, False])
    @pytest.mark.parametrize("classvar", _classvar_prefixes)
    def test_annotations_strings(self, slots, classvar):
        """
        String annotations are passed into __init__ as is.
        """

>       @attr.s(auto_attribs=True, slots=slots)
        class C:

tests/test_annotations.py:215:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @attr.s(auto_attribs=True, slots=slots)
    class C:
>       cls_var: classvar + "[int]" = 23
E       NameError: name 'classvar' is not defined

tests/test_annotations.py:217: NameError
__________________________________________________ TestAnnotations.test_annotations_strings[ClassVar-True] ___________________________________________________

self = <tests.test_annotations.TestAnnotations object at 0x0000000114e378a0>, slots = True, classvar = 'ClassVar'

    @pytest.mark.parametrize("slots", [True, False])
    @pytest.mark.parametrize("classvar", _classvar_prefixes)
    def test_annotations_strings(self, slots, classvar):
        """
        String annotations are passed into __init__ as is.
        """

>       @attr.s(auto_attribs=True, slots=slots)
        class C:

tests/test_annotations.py:215:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @attr.s(auto_attribs=True, slots=slots)
    class C:
>       cls_var: classvar + "[int]" = 23
E       NameError: name 'classvar' is not defined

tests/test_annotations.py:217: NameError
__________________________________________________ TestAnnotations.test_annotations_strings[ClassVar-False] __________________________________________________

self = <tests.test_annotations.TestAnnotations object at 0x0000000114e48e58>, slots = False, classvar = 'ClassVar'

    @pytest.mark.parametrize("slots", [True, False])
    @pytest.mark.parametrize("classvar", _classvar_prefixes)
    def test_annotations_strings(self, slots, classvar):
        """
        String annotations are passed into __init__ as is.
        """

>       @attr.s(auto_attribs=True, slots=slots)
        class C:

tests/test_annotations.py:215:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @attr.s(auto_attribs=True, slots=slots)
    class C:
>       cls_var: classvar + "[int]" = 23
E       NameError: name 'classvar' is not defined

tests/test_annotations.py:217: NameError
================================================================== short test summary info ===================================================================
SKIPPED [1] tests/test_make.py:411: No old-style classes in Py3
SKIPPED [1] tests/test_make.py:838: PY2-specific keyword-only error behavior
SKIPPED [1] tests/test_make.py:855: PY2-specific keyword-only error behavior
SKIPPED [1] tests/test_slots.py:414: ctypes are used only on CPython
SKIPPED [1] tests/test_slots.py:437: __slots__ only block weakref on CPython
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[typing.ClassVar-True]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[typing.ClassVar-False]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[t.ClassVar-True]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[t.ClassVar-False]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[ClassVar-True]
FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[ClassVar-False]
====================================================== 6 failed, 674 passed, 5 skipped in 14.40 seconds ======================================================
ERROR: InvocationError for command '/Users/hynek/Projects/attrs/.tox/pypy3/bin/python -m pytest' (exited with code 1)

hynek added a commit that referenced this issue Feb 25, 2019

@euresti

This comment has been minimized.

Copy link
Contributor

commented Feb 25, 2019

I assume you're talking about the Python 3.6 compatible PyPy3.6 v7.0.0-alpha

Playing around with pypy3 I think this could be a "bug" in that it only looks at global scope for these?

Take this code:

def foo(buf):
     print(buf)
     class A:
        b: buf + "t"
     print(A.__annotations__)
foo("in")  # This will fail
buf = "in"
foo("")  # This will work because buf is in the globals?
@euresti

This comment has been minimized.

Copy link
Contributor

commented Feb 25, 2019

PS. I think these tests are not gonna run well in Python3.8

from __future__ import annotations
def foo(buf):
     class A:
        b: buf + "t"
     print(A.__annotations__)

foo("in")  # {'b': "buf + 't'"}
@cfbolz

This comment has been minimized.

Copy link

commented Feb 25, 2019

can confirm, this is a pypy bug. will look into it.

@cfbolz

This comment has been minimized.

Copy link

commented Feb 25, 2019

This commit should have fixed the bug: https://bitbucket.org/pypy/pypy/commits/c79752d27d7056359af25141e7cc5dc953a34fba

Would you try again with a PyPy3.6 nightly tomorrow to see whether it's really gone?

mozillazg pushed a commit to mozillazg/pypy that referenced this issue Feb 26, 2019

@hynek

This comment has been minimized.

Copy link
Member Author

commented Feb 27, 2019

I can confirm the tests are passing now, thank you @cfbolz!

I'll leave this bug open until y'all release a new pypy3 release as a reminder, that I need to remove the if PYPY from conftest.

@wsanchez wsanchez added the Bug label May 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.