Skip to content

Instantly share code, notes, and snippets.

@cjw296
Created November 29, 2017 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjw296/82b8047e804a13dec35fb44b227a9703 to your computer and use it in GitHub Desktop.
Save cjw296/82b8047e804a13dec35fb44b227a9703 to your computer and use it in GitHub Desktop.
__________________ ERROR at setup of fail.rst line=1 column=1 __________________
self = <FixtureRequest for <SybilItem 'line:1,column:1'>>
fixturedef = <FixtureDef name='session_fixture' scope='session' baseid='' >
def _getfixturevalue(self, fixturedef):
# prepare a subrequest object before calling fixture function
# (latter managed by fixturedef)
argname = fixturedef.argname
funcitem = self._pyfuncitem
scope = fixturedef.scope
try:
param = funcitem.callspec.getparam(argname)
except (AttributeError, ValueError):
param = NOTSET
param_index = 0
if fixturedef.params is not None:
frame = inspect.stack()[3]
frameinfo = inspect.getframeinfo(frame[0])
source_path = frameinfo.filename
source_lineno = frameinfo.lineno
source_path = py.path.local(source_path)
if source_path.relto(funcitem.config.rootdir):
source_path = source_path.relto(funcitem.config.rootdir)
msg = (
"The requested fixture has no parameter defined for the "
"current test.\n\nRequested fixture '{0}' defined in:\n{1}"
"\n\nRequested here:\n{2}:{3}".format(
fixturedef.argname,
getlocation(fixturedef.func, funcitem.config.rootdir),
source_path,
source_lineno,
)
)
fail(msg)
else:
# indices might not be set if old-style metafunc.addcall() was used
param_index = funcitem.callspec.indices.get(argname, 0)
# if a parametrize invocation set a scope it will override
# the static scope defined with the fixture function
paramscopenum = funcitem.callspec._arg2scopenum.get(argname)
if paramscopenum is not None:
scope = scopes[paramscopenum]
subrequest = SubRequest(self, scope, param, param_index, fixturedef)
# check if a higher-level scoped fixture accesses a lower level one
subrequest._check_scope(argname, self.scope, scope)
# clear sys.exc_info before invoking the fixture (python bug?)
# if its not explicitly cleared it will leak into the call
exc_clear()
try:
# call the fixture function
> val = fixturedef.execute(request=subrequest)
../../../virtualenvs/sybil_35/lib/python3.5/site-packages/_pytest/fixtures.py:518:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <FixtureDef name='session_fixture' scope='session' baseid='' >
request = <SubRequest 'session_fixture' for <SybilItem 'line:1,column:1'>>
def execute(self, request):
# get required arguments and register our own finish()
# with their finalization
for argname in self.argnames:
fixturedef = request._get_active_fixturedef(argname)
if argname != "request":
fixturedef.addfinalizer(functools.partial(self.finish, request=request))
my_cache_key = request.param_index
cached_result = getattr(self, "cached_result", None)
if cached_result is not None:
result, cache_key, err = cached_result
if my_cache_key == cache_key:
if err is not None:
py.builtin._reraise(*err)
else:
return result
# we have a previous but differently parametrized fixture instance
# so we need to tear it down before creating a new one
self.finish(request)
assert not hasattr(self, "cached_result")
> hook = self._fixturemanager.session.gethookproxy(request.node.fspath)
../../../virtualenvs/sybil_35/lib/python3.5/site-packages/_pytest/fixtures.py:790:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <SubRequest 'session_fixture' for <SybilItem 'line:1,column:1'>>
@property
def node(self):
""" underlying collection node (depends on current request scope)"""
> return self._getscopeitem(self.scope)
../../../virtualenvs/sybil_35/lib/python3.5/site-packages/_pytest/fixtures.py:285:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <SubRequest 'session_fixture' for <SybilItem 'line:1,column:1'>>
scope = 'session'
def _getscopeitem(self, scope):
if scope == "function":
# this might also be a non-function Item despite its attribute name
return self._pyfuncitem
node = get_scope_node(self._pyfuncitem, scope)
if node is None and scope == "class":
# fallback to function item itself
node = self._pyfuncitem
> assert node
E AssertionError
../../../virtualenvs/sybil_35/lib/python3.5/site-packages/_pytest/fixtures.py:556: AssertionError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment