Skip to content

Commit

Permalink
Add e2e tests reading from / writing to file
Browse files Browse the repository at this point in the history
  • Loading branch information
kynan committed Feb 5, 2024
1 parent 0dc1cae commit 883d871
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def nbstripout_exe():


@pytest.mark.parametrize("input_file, expected_file, args", TEST_CASES)
def test_end_to_end_nbstripout(input_file: str, expected_file: str, args: List[str]):
def test_end_to_end_stdin(input_file: str, expected_file: str, args: List[str]):
with open(NOTEBOOKS_FOLDER / expected_file, mode="r") as f:
expected = f.read()

Expand All @@ -64,6 +64,19 @@ def test_end_to_end_nbstripout(input_file: str, expected_file: str, args: List[s
assert output == expected


@pytest.mark.parametrize("input_file, expected_file, args", TEST_CASES)
def test_end_to_end_file(input_file: str, expected_file: str, args: List[str], tmp_path):
with open(NOTEBOOKS_FOLDER / expected_file, mode="r") as f:
expected = f.read()

p = tmp_path / input_file
with open(NOTEBOOKS_FOLDER / input_file, mode="r") as f:
p.write_text(f.read())
pc = run([nbstripout_exe(), p] + args, stdout=PIPE, universal_newlines=True)

assert not pc.stdout and p.read_text() == expected


@pytest.mark.parametrize("input_file, extra_args", DRY_RUN_CASES)
def test_dry_run_stdin(input_file: str, extra_args: List[str]):
expected = "Dry run: would have stripped input from stdin\n"
Expand Down

0 comments on commit 883d871

Please sign in to comment.