pytest-sugar: AttributeError: 'NoneType' object has no attribute 'testscollected'

Running some tests on circleci and I get the following exception (see full stacktrace below).

When I don’t install pytest-sugar, test runs fine.

Oddly enough I cannot (yet) reproduce locally.

Command used to run py.test

py.test

Output

INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/main.py", line 185, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/main.py", line 225, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/main.py", line 246, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/runner.py", line 78, in pytest_runtest_protocol
INTERNALERROR>     item.ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/hooks.py", line 284, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/circleci/circleci/venv/lib/python3.7/site-packages/_pytest/terminal.py", line 432, in pytest_runtest_logfinish
INTERNALERROR>     len(self._progress_nodeids_reported) == self._session.testscollected
INTERNALERROR> AttributeError: 'NoneType' object has no attribute 'testscollected'

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Also, huge thanks to @blueyed for merging lots of PR and overall maintenance of this project. 🎉😇

thanks for the fix and the speed of the PR, when can expect a new release of pytest-sugar? 😃

I feel so horrible that I noticed this so late. I only got a notification to my email when I got an highlight from @blueyed 4 hours ago.

Anyway, 0.9.2. has been released. Hopefully nothing breaks since I did this in a hurry.

I’m seeing this as well:

Python and dependencies:

python --version
Python 3.6.6

pip freeze
atomicwrites==1.2.1
attrs==18.2.0
more-itertools==4.3.0
pluggy==0.8.0
py==1.7.0
pytest==3.10.0
pytest-sugar==0.9.1
six==1.11.0
termcolor==1.1.0

test_stuff.py:

def test_stuff():
    pass

def test_blah():
    pass

tox.ini

[tox]
envlist = py36
skipsdist = true

[testenv]
usedevelop = false
deps =
    pytest
    pytest-sugar
commands =
    pytest

But if I disable or remove pytest-sugar, this doesn’t happen.

FWIW, If I use pytest==3.9.3, pytest-sugar works.

Any rationale of why this is not a pytest-sugar 0.9.2 ?

This doesn’t just happen on Circle. Looks like pytest 3.10.0 isn’t supported atm.

I tried your new package, but I get this error while trying to use it

@Natim Did you also install pytest-sugar? I should have said you need the bugfix package in addition to pytest-sugar. The bugfix is just the patch.

a separate pytest-sugar-bugfix159 package makes no sense really, since it is easy to install master

I tried this technique, but unfortunately, it’s not always easy to put the override in the right place. There are projects where the pytest-sugar requirement is already pinned somewhere (by pip-compile) and updating it to use another download technique proved difficult and error-prone, whereas simply adding an additional requirement to the tox environment was sufficient to both work around the issue in a variety of environments but also in the same line document the meaning of it.

@Natim Because 0.9.2 would be next? 😉 Please stay calm, only @Frozenball can cut a release.

Since pytest 3.10 has other severe bugs it is good to wait for 3.10.1 there also anyway, btw. Apart from that I do not recommend to use pytest-sugar for CI/prod for reasons like this anyway.

I agree that a separate pytest-sugar-bugfix159 package makes no sense really, since it is easy to install master (or even a branch PR) instead.

I worked around the issue by adding this to conftest.py:

def pytest_configure():
	workaround_sugar_issue_159()


def workaround_sugar_issue_159():
	"https://github.com/Frozenball/pytest-sugar/159"
	import pytest_sugar
	pytest_sugar.SugarTerminalReporter.pytest_runtest_logfinish = \
		lambda self: None