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

Crash when doctest fails #122

Closed
jaraco opened this issue Apr 19, 2017 · 4 comments · Fixed by pytest-dev/pytest#2610
Closed

Crash when doctest fails #122

jaraco opened this issue Apr 19, 2017 · 4 comments · Fixed by pytest-dev/pytest#2610

Comments

@jaraco
Copy link

jaraco commented Apr 19, 2017

When running pytest with --doctest-modules and if one of the doctests fails, pytest-sugar fails with a TypeError. For example, here's the invocation of tox on this repro repo:

python create: /Users/jaraco/issue-N/.tox/python
python installdeps: -rtests/requirements.txt
python develop-inst: /Users/jaraco/issue-N
python installed: ----------------------------------------,Error when trying to get requirement for VCS system Command "git config --get-regexp remote\..*\.url" failed with error code 1 in /Users/jaraco/issue-N, falling back to uneditable format,Could not determine repository location of /Users/jaraco/issue-N,appdirs==1.4.3,packaging==16.8,py==1.4.33,pyparsing==2.2.0,pytest==3.0.7,pytest-sugar==0.8.0,six==1.10.0,## !! Could not determine repository location,skeleton==0.1.dev59+g23dae90,termcolor==1.1.0
python runtests: PYTHONHASHSEED='2034398031'
python runtests: commands[0] | py.test
Test session starts (platform: darwin, Python 3.6.1, pytest 3.0.7, pytest-sugar 0.8.0)
rootdir: /Users/jaraco/issue-N, inifile: pytest.ini
plugins: sugar-0.8.0


――――――――――――――――――――――――――――――――――――――――― [doctest] mod ――――――――――――――――――――――――――――――――――――――――――
001 
002 Just a failing doctest
003 
004 >>> 1
Expected:
    0
Got:
    1

/Users/jaraco/issue-N/pkg/mod.py:4: DocTestFailure

 pkg/mod.py ⨯                                                                      100% ██████████

Results (0.10s):
       1 failed
Traceback (most recent call last):
  File "/Users/jaraco/issue-N/.tox/python/bin/py.test", line 11, in <module>
    sys.exit(main())
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/config.py", line 57, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/main.py", line 127, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/main.py", line 122, in wrap_session
    exitstatus=session.exitstatus)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/_pytest/terminal.py", line 374, in pytest_sessionfinish
    self.summary_stats()
  File "/Users/jaraco/issue-N/.tox/python/lib/python3.6/site-packages/pytest_sugar.py", line 494, in summary_stats
    report.location[1] + 1,
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
ERROR: InvocationError: '/Users/jaraco/issue-N/.tox/python/bin/py.test'
____________________________________________ summary _____________________________________________
ERROR:   python: commands failed
@jaraco
Copy link
Author

jaraco commented Jul 11, 2017

This issue is a blocker for me. If I can't find a solution for it, I will need to cease use of pytest-sugar in environments where doctests are used.

Are there plans to address this issue? Would you accept a PR with a fix and cut a release of it in short order?

@hongquan
Copy link

It is because pytest-sugar graps the report from this

    def reportinfo(self):
        return self.fspath, None, "[doctest] %s" % self.name

which returns None for lineno.

@Teemu
Copy link
Owner

Teemu commented Oct 17, 2018

#134

@Teemu
Copy link
Owner

Teemu commented Oct 17, 2018

I am closing this as #134 is going to be the single ticket related to doctest

@Teemu Teemu closed this as completed Oct 17, 2018
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 a pull request may close this issue.

3 participants