Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

doctest.DocTestFinder().find() and inspect.unwrap() dislikes Client #51

Closed
jayvdb opened this issue Aug 17, 2018 · 0 comments
Closed

doctest.DocTestFinder().find() and inspect.unwrap() dislikes Client #51

jayvdb opened this issue Aug 17, 2018 · 0 comments

Comments

@jayvdb
Copy link

jayvdb commented Aug 17, 2018

We've encountered a bug when doctest.DocTestFinder().find() is used with ramlient.Client.

coala/corobo#616 is example of enabling pytest --doctest-modules and
https://travis-ci.org/coala/corobo/builds/416950463 shows the failure.

It makes no difference which .raml is loaded; any variable wih an instance of Client will trigger it.

Here is a simplified case.

$ wget https://raw.githubusercontent.com/coala/corobo/master/webservices.raml
$ echo 'from ramlient import Client; client=Client("webservices.raml")' > doctest_bug.py
$ PYTHONPATH=. python3
>>> import doctest_bug
>>> import doctest
>>> finder = doctest.DocTestFinder()
>>> finder.find(import_ramlient)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.7/doctest.py", line 933, in find
    self._find(tests, obj, name, module, source_lines, globs, {})
  File "/usr/lib64/python3.7/doctest.py", line 996, in _find
    if ((inspect.isroutine(inspect.unwrap(val))
  File "/usr/lib64/python3.7/inspect.py", line 511, in unwrap
    while _is_wrapper(func):
  File "/usr/lib64/python3.7/inspect.py", line 502, in _is_wrapper
    return hasattr(f, '__wrapped__')
  File "/home/jayvdb/.local/lib/python3.7/site-packages/ramlient/core.py", line 132, in __getattr__
    raise ResourceNotFoundError(attr)
ramlient.errors.ResourceNotFoundError: No such Resource found: __wrapped__

https://docs.python.org/3/library/inspect.html#inspect.unwrap was added in Python 3.4 , but it wasnt used in doctest (&pydoc) until Python 3.5. python/cpython@b532df62b9

I guess it is a fairly simply thing to workaround in __getattr__. We'll submit a patch shortly.

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

No branches or pull requests

1 participant