@@ -1882,7 +1882,6 @@ def hook(
18821882 if PathFinder.find_spec has been called.
18831883 """
18841884 import importlib .machinery
1885-
18861885 self .find_spec_calls : list [str ] = []
18871886 self .initial_paths : set [Path ] = set ()
18881887
@@ -1956,6 +1955,7 @@ def test_simple_failure():
19561955 assert hook .find_spec ("file" ) is not None
19571956 assert self .find_spec_calls == ["file" ]
19581957
1958+
19591959 def test_assert_excluded_rootpath (
19601960 self , pytester : Pytester , hook : AssertionRewritingHook , monkeypatch
19611961 ) -> None :
@@ -1970,12 +1970,26 @@ def test_simple_failure():
19701970 """
19711971 }
19721972 )
1973+ with mock .patch .object (hook , "fnpats" , ["*.py" ]):
1974+ assert hook .find_spec ("file" ) is not None
19731975 root_path = f"{ os .getcwd ()} /tests"
1974- mkdir (root_path )
1976+
1977+ if not os .path .exists (root_path ):
1978+ mkdir (root_path )
19751979 monkeypatch .chdir (root_path )
19761980 with mock .patch .object (hook , "fnpats" , ["*.py" ]):
19771981 assert hook .find_spec ("file" ) is None
19781982
1983+
1984+ def test_assert_excluded_rewrite_for_plugins (
1985+ self , pytester : Pytester , hook : AssertionRewritingHook , monkeypatch
1986+ ) -> None :
1987+ plugins = {"ayncio" , "fnpats" , "pytest_bdd" , "django" , "mock" , "pytest_twisted" , "trio" }
1988+ with mock .patch .object (hook , "fnpats" , ["*.py" ]):
1989+ for plugin in plugins :
1990+ assert hook .find_spec (plugin ) is None
1991+
1992+
19791993 @pytest .mark .skipif (
19801994 sys .platform .startswith ("win32" ), reason = "cannot remove cwd on Windows"
19811995 )
0 commit comments