[Pyobjc-dev] doctest and PyObjC
Brought to you by:
ronaldoussoren
|
From: Just v. R. <jus...@gm...> - 2018-01-06 19:40:04
|
Hello,
I’m having trouble with integrating PyObjC and doctest. Whenever a module contains an NSObject subclass, the doctest test discovery code fails like so:
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.py", line 1950, in testmod
for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.py", 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.py", line 996, in _find
globs, seen)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.py", line 1027, in _find
self._from_module(module, val)):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/doctest.py", line 954, in _from_module
obj_mod = object.__objclass__.__module__
AttributeError: 'NoneType' object has no attribute ‘__module__'
Simplest way to reproduce:
=========
from Foundation import NSObject
class Foo(NSObject):
pass
import doctest
doctest.testmod()
=========
I can’t judge whether this is a bug in doctest or in PyObjC.
Is there a workaround?
My problem is not so much that I can’t use doctest in NSObject subclasses, but rather that test discovery fails in general in the vicinity of PyObjC code. For example, I can’t use pytest’s test discovery at all: it simply fails any module that contains an NSObject subclass.
Thanks for any insights,
Just
|