Skip to content

AttributeError: 'NoneType' object has no attribute 'option' when trying to use import pytest; pytest.set_trace() from within test #2328

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

Closed
cjw296 opened this issue Mar 23, 2017 · 4 comments

Comments

@cjw296
Copy link

cjw296 commented Mar 23, 2017

While trying to debug #2327, I inserted import pytest; pytest.set_trace() here:

https://github.com/cjw296/sybil/blob/32e7dc509026a2b18ff792e797b7db416c594185/tests/test_functional.py#L54

This resulted in:

______________________________________________________________________________________ test_unittest ______________________________________________________________________________________

capsys = <_pytest.capture.CaptureFixture object at 0x1038330b8>

    def test_unittest(capsys):
        main = unittest_main(
            exit=False, module=None,
            argv=['x', 'discover', '-v', join(functional_test_dir, 'unittest')]
        )
        # assert main.result.testsRun == 8
        assert len(main.result.failures) == 1
        assert len(main.result.errors) == 1
    
>       import pytest; pytest.set_trace()

tests/test_functional.py:55: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../virtualenvs/sybil_35/lib/python3.5/site-packages/_pytest/debugging.py:59: in set_trace
    tw = _pytest.config.create_terminal_writer(self._config)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

config = None, args = (), kwargs = {}, tw = <py._io.terminalwriter.TerminalWriter object at 0x103833550>

    def create_terminal_writer(config, *args, **kwargs):
        """Create a TerminalWriter instance configured according to the options
        in the config object. Every code which requires a TerminalWriter object
        and has access to a config object should use this function.
        """
        tw = py.io.TerminalWriter(*args, **kwargs)
>       if config.option.color == 'yes':
E       AttributeError: 'NoneType' object has no attribute 'option'

../../../virtualenvs/sybil_35/lib/python3.5/site-packages/_pytest/config.py:1346: AttributeError

This behaviour is the same across Python 2.7 and Python 3.5

@RonnyPfannschmidt
Copy link
Member

i believe this is a duplicate of #1658

i also believe my pr wrt removing the namespace hook usage should fix it (as i had to add better support for nested sessions) unfortunately i cant give an eta

@cjw296
Copy link
Author

cjw296 commented Mar 23, 2017

It certainly sounds similar, what's an "inline collect" and how am I likely to have triggered one?

@RonnyPfannschmidt
Copy link
Member

actually, let me check the code again, self._config shouldn't be none in _pytest/debugging.py

@RonnyPfannschmidt
Copy link
Member

closing as duplicate of #1658

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

No branches or pull requests

2 participants