Re: doctest and PyObjC
Ronald Oussoren <[email protected]> Sun, 04 Feb 2018 12:29:36 +0100
| Newsgroups | gmane.comp.python.pyobjc.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============1779286505531789879== Content-type: multipart/alternative; boundary="Apple-Mail=_A1D51C9A-8B23-45FF-8E08-A0B290D427ED" --Apple-Mail=_A1D51C9A-8B23-45FF-8E08-A0B290D427ED Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I=E2=80=99ve just pushed a fix to the repository. I=E2=80=99m hoping to = push out a new release next weekend. There is no workaround for the issue other than patching PyObjC: In = Lib/objc/_convenience.py remove the @register decorator from = makeBundleForClass. I had hoped that there=E2=80=99d be a cleaner = workaround, but that workaround caused a hard crash (also fixed in the = repository). Ronald > On 28 Jan 2018, at 19:28, Ronald Oussoren <[email protected]> = wrote: >=20 >=20 >=20 >> On 6 Jan 2018, at 20:39, Just van Rossum <[email protected]> = wrote: >>=20 >> Hello, >>=20 >> I=E2=80=99m having trouble with integrating PyObjC and doctest. = Whenever a module contains an NSObject subclass, the doctest test = discovery code fails like so: >>=20 >>=20 >> Traceback (most recent call last): >> File "Lib/typemachine/ui/appDelegate.py", line 54, in <module> >> doctest.testmod() >> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 1950, in testmod >> for test in finder.find(m, name, globs=3Dglobs, = extraglobs=3Dextraglobs): >> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 933, in find >> self._find(tests, obj, name, module, source_lines, globs, {}) >> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 996, in _find >> globs, seen) >> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 1027, in _find >> self._from_module(module, val)): >> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 954, in _from_module >> obj_mod =3D object.__objclass__.__module__ >> AttributeError: 'NoneType' object has no attribute =E2=80=98__module__'= >>=20 >>=20 >> Simplest way to reproduce: >>=20 >> =3D=3D=3D=3D=3D=3D=3D=3D=3D >> from Foundation import NSObject >>=20 >> class Foo(NSObject): >> pass >>=20 >> import doctest >> doctest.testmod() >> =3D=3D=3D=3D=3D=3D=3D=3D=3D >>=20 >> I can=E2=80=99t judge whether this is a bug in doctest or in PyObjC. >>=20 >> Is there a workaround? >>=20 >> My problem is not so much that I can=E2=80=99t use doctest in = NSObject subclasses, but rather that test discovery fails in general in = the vicinity of PyObjC code. For example, I can=E2=80=99t use pytest=E2=80= =99s test discovery at all: it simply fails any module that contains an = NSObject subclass. >>=20 >> Thanks for any insights, >=20 > This appears to be a bug. I don=E2=80=99t have a workaround yet, but = am investigating. >=20 > Ronald >=20 >=20 > = --------------------------------------------------------------------------= ---- > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Pyobjc-dev mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev --Apple-Mail=_A1D51C9A-8B23-45FF-8E08-A0B290D427ED Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;" = class=3D"">I=E2=80=99ve just pushed a fix to the repository. I=E2=80=99m = hoping to push out a new release next weekend.<div class=3D""><br = class=3D""></div><div class=3D"">There is no workaround for the issue = other than patching PyObjC: In <span style=3D"background-color: = rgb(255, 255, 255);" class=3D""><font face=3D"Menlo" class=3D""><span = style=3D"font-size: 11px;" class=3D"">Lib/objc/_convenience.py remove = the @register decorator from makeBundleForClass. I had hoped that = there=E2=80=99d be a cleaner workaround, but that workaround caused a = hard crash (also fixed in the repository).</span></font></span><div = class=3D""><br class=3D""></div><div class=3D"">Ronald</div><div = class=3D""><br class=3D""></div><div class=3D""><br = class=3D""></div><div><br class=3D""><blockquote type=3D"cite" = class=3D""><div class=3D"">On 28 Jan 2018, at 19:28, Ronald Oussoren = <<a href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:</div><br = class=3D"Apple-interchange-newline"><div class=3D""><div class=3D""><br = class=3D""><br class=3D""><blockquote type=3D"cite" class=3D"">On 6 Jan = 2018, at 20:39, Just van Rossum <<a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a>> wrote:<br class=3D""><br = class=3D"">Hello,<br class=3D""><br class=3D"">I=E2=80=99m having = trouble with integrating PyObjC and doctest. Whenever a module contains = an NSObject subclass, the doctest test discovery code fails like so:<br = class=3D""><br class=3D""><br class=3D"">Traceback (most recent call = last):<br class=3D""> File "Lib/typemachine/ui/appDelegate.py", line 54, = in <module><br class=3D""> doctest.testmod()<br = class=3D""> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 1950, in testmod<br class=3D""> for test in = finder.find(m, name, globs=3Dglobs, extraglobs=3Dextraglobs):<br = class=3D""> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 933, in find<br class=3D""> self._find(tests, obj, = name, module, source_lines, globs, {})<br class=3D""> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 996, in _find<br class=3D""> globs, seen)<br = class=3D""> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 1027, in _find<br class=3D""> = self._from_module(module, val)):<br class=3D""> File = "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.p= y", line 954, in _from_module<br class=3D""> obj_mod =3D = object.__objclass__.__module__<br class=3D"">AttributeError: 'NoneType' = object has no attribute =E2=80=98__module__'<br class=3D""><br = class=3D""><br class=3D"">Simplest way to reproduce:<br class=3D""><br = class=3D"">=3D=3D=3D=3D=3D=3D=3D=3D=3D<br class=3D"">from Foundation = import NSObject<br class=3D""><br class=3D"">class Foo(NSObject):<br = class=3D""> pass<br class=3D""><br class=3D"">import = doctest<br class=3D"">doctest.testmod()<br class=3D"">=3D=3D=3D=3D=3D=3D=3D= =3D=3D<br class=3D""><br class=3D"">I can=E2=80=99t judge whether this = is a bug in doctest or in PyObjC.<br class=3D""><br class=3D"">Is there = a workaround?<br class=3D""><br class=3D"">My problem is not so much = that I can=E2=80=99t use doctest in NSObject subclasses, but rather that = test discovery fails in general in the vicinity of PyObjC code. For = example, I can=E2=80=99t use pytest=E2=80=99s test discovery at all: it = simply fails any module that contains an NSObject subclass.<br = class=3D""><br class=3D"">Thanks for any insights,<br = class=3D""></blockquote><br class=3D"">This appears to be a bug. I = don=E2=80=99t have a workaround yet, but am investigating.<br = class=3D""><br class=3D"">Ronald<br class=3D""><br class=3D""><br = class=3D"">---------------------------------------------------------------= ---------------<br class=3D"">Check out the vibrant tech community on = one of the world's most<br class=3D"">engaging tech sites, <a = href=3D"http://Slashdot.org" class=3D"">Slashdot.org</a>! <a = href=3D"http://sdm.link/slashdot" = class=3D"">http://sdm.link/slashdot</a><br = class=3D"">_______________________________________________<br = class=3D"">Pyobjc-dev mailing list<br class=3D""><a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a><br = class=3D"">https://lists.sourceforge.net/lists/listinfo/pyobjc-dev<br = class=3D""></div></div></blockquote></div><br = class=3D""></div></body></html>= --Apple-Mail=_A1D51C9A-8B23-45FF-8E08-A0B290D427ED-- --===============1779286505531789879== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot --===============1779286505531789879== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Pyobjc-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyobjc-dev --===============1779286505531789879==--