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

Fix test incompatibility with zope.interface 5.0 #18

Merged
merged 2 commits into from
Apr 7, 2020

Conversation

mgedmin
Copy link
Member

@mgedmin mgedmin commented Apr 7, 2020

Recent zope.interface versions made Interface.__module__ a readonly attribute. Without this fix, tests fail on Python 2.7 with

Traceback (most recent call last):
  File "/usr/lib/python2.7/doctest.py", line 1315, in __run
    compileflags, 1) in test.globs
  File "<doctest directive.rst[105]>", line 1, in <module>
    class once_iface(FakeModule):
  File "/home/mg/src/zopefoundation/martian/src/martian/testing.py", line 65, in __init__
    fake_import(cls)
  File "/home/mg/src/zopefoundation/martian/src/martian/testing.py", line 33, in fake_import
    obj.__module__ = module.__name__
TypeError: readonly attribute

(On Python 3 assignment to a readonly attribute raises an AttributeError instead, which was already caught.)

Recent zope.interface versions made Interface.__module__ a readonly
attribute.  Without this fix, tests fail on Python 2.7 with

    Traceback (most recent call last):
      File "/usr/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest directive.rst[105]>", line 1, in <module>
        class once_iface(FakeModule):
      File "/home/mg/src/zopefoundation/martian/src/martian/testing.py", line 65, in __init__
        fake_import(cls)
      File "/home/mg/src/zopefoundation/martian/src/martian/testing.py", line 33, in fake_import
        obj.__module__ = module.__name__
    TypeError: readonly attribute

(On Python 3 assignment to a readonly attribute raises an AttributeError
instead, which was already caught.)
@mgedmin mgedmin mentioned this pull request Apr 7, 2020
Copy link
Member

@jamadden jamadden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about this package, but this change LGTM.

Maybe leave a comment about why we need to catch TypeError and that it's a python-2-ism?

Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mgedmin
Copy link
Member Author

mgedmin commented Apr 7, 2020

Maybe leave a comment about why we need to catch TypeError and that it's a python-2-ism?

It's in the commit message, which is Good Enough For Me ™️

@mgedmin mgedmin merged commit a9833ba into master Apr 7, 2020
@mgedmin mgedmin deleted the fix-readonly-module-attribute branch April 7, 2020 12:43
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

Successfully merging this pull request may close these issues.

None yet

3 participants