Created
February 19, 2022 18:08
-
-
Save tkutcher/200bcc4e6a92ec1614b5d5367aa6cc26 to your computer and use it in GitHub Desktop.
Python File IO Demo 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture() | |
def res_dir(): | |
return pathlib.Path(__file__).parent / "res" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Optionally provide specific file regerences through a fixture if they are | |
# common or reused: | |
@pytest.fixture() | |
def example_config_001(res_dir): | |
return res_dir / "example-config-001.json" | |
def test_read_from_file_1(example_config_001): | |
c = read_from_file(example_config_001) | |
assert c.x == "3" | |
def test_read_from_file_2(res_dir): | |
c = read_from_file(res_dir / "example-config-002.json") | |
assert c.x == "18" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment