Merge .set_config() into constructor
This commit is contained in:
parent
e0cb046885
commit
9118c0222f
|
@ -76,8 +76,7 @@ def pytest_load_initial_conftests(early_config, parser, args):
|
||||||
|
|
||||||
hook = None
|
hook = None
|
||||||
if mode == "rewrite":
|
if mode == "rewrite":
|
||||||
hook = rewrite.AssertionRewritingHook() # noqa
|
hook = rewrite.AssertionRewritingHook(early_config) # noqa
|
||||||
hook.set_config(early_config)
|
|
||||||
sys.meta_path.insert(0, hook)
|
sys.meta_path.insert(0, hook)
|
||||||
|
|
||||||
early_config._assertstate.hook = hook
|
early_config._assertstate.hook = hook
|
||||||
|
|
|
@ -44,7 +44,9 @@ else:
|
||||||
class AssertionRewritingHook(object):
|
class AssertionRewritingHook(object):
|
||||||
"""PEP302 Import hook which rewrites asserts."""
|
"""PEP302 Import hook which rewrites asserts."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, config):
|
||||||
|
self.config = config
|
||||||
|
self.fnpats = config.getini("python_files")
|
||||||
self.session = None
|
self.session = None
|
||||||
self.modules = {}
|
self.modules = {}
|
||||||
self._register_with_pkg_resources()
|
self._register_with_pkg_resources()
|
||||||
|
@ -52,10 +54,6 @@ class AssertionRewritingHook(object):
|
||||||
def set_session(self, session):
|
def set_session(self, session):
|
||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
def set_config(self, config):
|
|
||||||
self.config = config
|
|
||||||
self.fnpats = config.getini("python_files")
|
|
||||||
|
|
||||||
def find_module(self, name, path=None):
|
def find_module(self, name, path=None):
|
||||||
state = self.config._assertstate
|
state = self.config._assertstate
|
||||||
state.trace("find_module called for: %s" % name)
|
state.trace("find_module called for: %s" % name)
|
||||||
|
|
Loading…
Reference in New Issue