Skip to content

Commit 9118c02

Browse files
committed
Merge .set_config() into constructor
1 parent e0cb046 commit 9118c02

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

_pytest/assertion/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ def pytest_load_initial_conftests(early_config, parser, args):
7676

7777
hook = None
7878
if mode == "rewrite":
79-
hook = rewrite.AssertionRewritingHook() # noqa
80-
hook.set_config(early_config)
79+
hook = rewrite.AssertionRewritingHook(early_config) # noqa
8180
sys.meta_path.insert(0, hook)
8281

8382
early_config._assertstate.hook = hook

_pytest/assertion/rewrite.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,16 @@
4444
class AssertionRewritingHook(object):
4545
"""PEP302 Import hook which rewrites asserts."""
4646

47-
def __init__(self):
47+
def __init__(self, config):
48+
self.config = config
49+
self.fnpats = config.getini("python_files")
4850
self.session = None
4951
self.modules = {}
5052
self._register_with_pkg_resources()
5153

5254
def set_session(self, session):
5355
self.session = session
5456

55-
def set_config(self, config):
56-
self.config = config
57-
self.fnpats = config.getini("python_files")
58-
5957
def find_module(self, name, path=None):
6058
state = self.config._assertstate
6159
state.trace("find_module called for: %s" % name)

0 commit comments

Comments
 (0)