55from typing import Any
66
77import pytest
8+ import toml
9+ import yaml
810from _pytest .fixtures import FixtureRequest
911from _pytest .tmpdir import TempPathFactory
1012from cookiecutter .main import cookiecutter
@@ -21,6 +23,32 @@ def demos_folder(tmp_path_factory: TempPathFactory) -> Path:
2123 return tmp_path_factory .mktemp ("demos" )
2224
2325
26+ @pytest .fixture (scope = "session" )
27+ def robust_yaml (request : FixtureRequest , robust_file : str ) -> dict [str , Any ]:
28+ return getattr (request , "param" , yaml .safe_load (robust_file ))
29+
30+
31+ @pytest .fixture (scope = "session" )
32+ def robust_toml (request : FixtureRequest , robust_file : str ) -> dict [str , Any ]:
33+ return getattr (request , "param" , toml .load (robust_file ))
34+
35+
36+ @pytest .fixture (scope = "session" )
37+ def robust_file (request : FixtureRequest , robust_file__path : Path ) -> str :
38+ text : str = robust_file__path .read_text ()
39+ return getattr (request , "param" , text )
40+
41+
42+ @pytest .fixture (scope = "session" )
43+ def robust_file__path (request : FixtureRequest , robust_demo : Path , robust_file__path__relative : str ) -> Path :
44+ return getattr (request , "param" , robust_demo / robust_file__path__relative )
45+
46+
47+ @pytest .fixture (scope = "session" )
48+ def robust_file__path__relative (request : FixtureRequest ) -> str :
49+ return getattr (request , "param" , "./pyproject.toml" )
50+
51+
2452@pytest .fixture (scope = "session" )
2553def robust_demo (
2654 request : FixtureRequest ,
0 commit comments