Relative paths are relative to current working directory. If you do not want your path to be relative, it must be absolute. from pathlib import Path path = Path(__file__).parent / "../data/test.csv" with path.open() as f: test = list(csv.reader(f)) from pathlib import Path import pytest @pytest.fixture() def sfn_definition() -> str: # Read the step function definition from a file definition_path = Path(__file__).parent / "../step_function_definition.asl.json" with definition_path.open() as f: definition = f.read() return json.dumps(definition) Links https://stackoverflow.com/questions/40416072/reading-a-file-using-a-relative-path-in-a-python-project