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

AttributeError: 'Session' object has no attribute '_setupstate' #49

Closed
pytestbot opened this issue Jun 1, 2011 · 1 comment
Closed
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Ralf Schmitt (BitBucket: schmir, GitHub: schmir)


Running py.test inside a directory, only containing conftest.py with the following contents:

def pytest_configure(config):

    import no_such_module

I get the following error

[py27]  ~/pytest-internal-error/ % py.test
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/main.py", line 62, in wrap_session
INTERNALERROR>     config.pluginmanager.do_configure(config)
INTERNALERROR>   File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 260, in do_configure
INTERNALERROR>     config.hook.pytest_configure(config=self._config)
INTERNALERROR>   File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 412, in __call__
INTERNALERROR>     return self._docall(methods, kwargs)
INTERNALERROR>   File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 423, in _docall
INTERNALERROR>     res = mc.execute()
INTERNALERROR>   File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 341, in execute
INTERNALERROR>     res = method(**kwargs)
INTERNALERROR>   File "/home/ralf/pytest-internal-error/conftest.py", line 2, in pytest_configure
INTERNALERROR>     import no_such_module
INTERNALERROR> ImportError: No module named no_such_module
INTERNALERROR> 
Traceback (most recent call last):
  File "/home/ralf/local/bin/py.test", line 9, in <module>
    load_entry_point('pytest==2.1.0.dev3', 'console_scripts', 'py.test')()
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 458, in main
    exitstatus = hook.pytest_cmdline_main(config=config)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 412, in __call__
    return self._docall(methods, kwargs)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 423, in _docall
    res = mc.execute()
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 341, in execute
    res = method(**kwargs)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/main.py", line 85, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/main.py", line 80, in wrap_session
    exitstatus=session.exitstatus)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 412, in __call__
    return self._docall(methods, kwargs)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 423, in _docall
    res = mc.execute()
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 341, in execute
    res = method(**kwargs)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/runner.py", line 22, in pytest_sessionfinish
    rep = hook.pytest__teardown_final(session=session)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 412, in __call__
    return self._docall(methods, kwargs)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 423, in _docall
    res = mc.execute()
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 341, in execute
    res = method(**kwargs)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/capture.py", line 171, in pytest__teardown_final
    rep = __multicall__.execute()
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/core.py", line 341, in execute
    res = method(**kwargs)
  File "/home/ralf/local/lib/python2.7/site-packages/pytest-2.1.0.dev3-py2.7.egg/_pytest/runner.py", line 56, in pytest__teardown_final
    call = CallInfo(session._setupstate.teardown_all, when="teardown")
AttributeError: 'Session' object has no attribute '_setupstate'

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue49 - avoid confusing errors when initialization goes wrong

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
Note: if those are handled, you can't use --safe because this check is using
Python 3.6+ builtin AST.

Fixes pytest-dev#49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant