Skip to content

Instantly share code, notes, and snippets.

@tkutcher
Created February 19, 2022 18:08
Show Gist options
  • Save tkutcher/200bcc4e6a92ec1614b5d5367aa6cc26 to your computer and use it in GitHub Desktop.
Save tkutcher/200bcc4e6a92ec1614b5d5367aa6cc26 to your computer and use it in GitHub Desktop.
Python File IO Demo 4
@pytest.fixture()
def res_dir():
return pathlib.Path(__file__).parent / "res"
# 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