30
30
from _pytest .assertion .rewrite import _get_maxsize_for_saferepr
31
31
from _pytest .assertion .rewrite import _saferepr
32
32
from _pytest .assertion .rewrite import AssertionRewritingHook
33
+ from _pytest .assertion .rewrite import assertstate_key
33
34
from _pytest .assertion .rewrite import get_cache_dir
34
35
from _pytest .assertion .rewrite import PYC_TAIL
35
36
from _pytest .assertion .rewrite import PYTEST_TAG
@@ -2002,7 +2003,7 @@ def test_simple_failure():
2002
2003
assert hook .find_spec ("file" ) is not None
2003
2004
assert self .find_spec_calls == ["file" ]
2004
2005
2005
- def test_assert_rewrites_only_rootpath (
2006
+ def test_assert_rewrites_only_invocation_path (
2006
2007
self , pytester : Pytester , hook : AssertionRewritingHook , monkeypatch
2007
2008
) -> None :
2008
2009
"""Do not rewrite assertions in tests outside `AssertState.rootpath` (#13403)."""
@@ -2014,21 +2015,19 @@ def test_simple_failure():
2014
2015
"""
2015
2016
}
2016
2017
)
2018
+
2017
2019
with mock .patch .object (hook , "fnpats" , ["*.py" ]):
2018
2020
assert hook .find_spec ("file" ) is not None
2019
2021
2020
- rootpath = f"{ os .getcwd ()} /tests"
2021
- if not os .path .exists (rootpath ):
2022
- mkdir (rootpath )
2022
+ invocation_path = f"{ os .getcwd ()} /tests"
2023
+ if not os .path .exists (invocation_path ):
2024
+ mkdir (invocation_path )
2023
2025
monkeypatch .setattr (
2024
- pytester ._request .config ,
2025
- "invocation_params" ,
2026
- Config .InvocationParams (
2027
- args = (),
2028
- plugins = (),
2029
- dir = Path (rootpath ),
2030
- ),
2026
+ pytester ._request .config .stash [assertstate_key ],
2027
+ "invocation_path" ,
2028
+ invocation_path ,
2031
2029
)
2030
+
2032
2031
with mock .patch .object (hook , "fnpats" , ["*.py" ]):
2033
2032
assert hook .find_spec ("file" ) is None
2034
2033
0 commit comments