mattduck / pytest-it

Decorate your pytest suite with RSpec-style pytest markers, then run `pytest --it` to see a plaintext spec of the test structure.
MIT License
35 stars 6 forks source link

Errors when run doctests #1

Closed bigfang closed 5 years ago

bigfang commented 5 years ago

pytest-it is my missing pytest plugin,I install the github version

pip install git+https://github.com/mattduck/pytest-it.git

and found it work fine if without doctests,

error message

$ pytest --it --doctest-modules
============================= test session starts ==============================
platform darwin -- Python 3.7.3, pytest-4.6.2, py-1.8.0, pluggy-0.12.0
rootdir: /Users/fang/repo/horn-py, inifile: setup.cfg, testpaths: horn, tests
plugins: it-0.1, cov-2.7.1, spec-1.1.0

* horn/tpl.py...                                                                                  
- ✓ horn.tpl.merge_fields

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/_pytest/main.py", line 206, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/_pytest/main.py", line 250, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/_pytest/main.py", line 271, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/_pytest/runner.py", line 78, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/_pytest/runner.py", line 93, in runtestprotocol
INTERNALERROR>     reports.append(call_and_report(item, "call", log))
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/_pytest/runner.py", line 177, in call_and_report
INTERNALERROR>     hook.pytest_runtest_logreport(report=report)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/manager.py", line 87, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/manager.py", line 81, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pytest_it/plugin.py", line 226, in pytest_runtest_logreport
INTERNALERROR>     item.reconcile_and_print(self._prev_item, self._tw, report.outcome)
INTERNALERROR>   File "/Users/fang/.local/share/virtualenvs/horn-py-avlOfzi3/lib/python3.7/site-packages/pytest_it/plugin.py", line 137, in reconcile_and_print
INTERNALERROR>     is_first_module_test = self._item.module != prev._item.module
INTERNALERROR> AttributeError: 'DoctestItem' object has no attribute 'module'

=========================== 2 passed in 0.24 seconds ===========================
mattduck commented 5 years ago

Hi! Sorry, I completely missed this issue - forgot to watch the Github repo when I first created it so I didn't get a notification.

Thanks for the report - I will look into it.

mattduck commented 5 years ago

@bigfang This is now fixed on master. I only tested it with a couple of basic doctests, so let me know if it still errors for your use-case or if the formatting is broken. I'm closing this - thanks again for the report!