Verified Commit 3351f405 authored by Duncan Macleod's avatar Duncan Macleod
Browse files

tests: don't yield open file in input_file fixtures

that doesn't work on windows
parent a59c3023
......@@ -33,9 +33,9 @@ def isolated_cli(cli):
@pytest.fixture
def input_file():
def input_file(tmp_path):
"""A temporary file containing valid kat script."""
with NamedTemporaryFile("r+") as fobj:
tmpfile = tmp_path / "kat.tmp"
with open(tmpfile, "w") as fobj:
fobj.write(SCRIPT)
fobj.flush()
yield fobj
yield str(tmpfile)
......@@ -6,6 +6,6 @@ from .util import sanitized_output
def test_info(cli, input_file):
"""Test info output."""
cli_result = cli.invoke(info, [input_file.name])
cli_result = cli.invoke(info, [input_file])
assert "Summary:" in sanitized_output(cli_result)
assert cli_result.exit_code == 0
......@@ -8,9 +8,9 @@ from .util import sanitized_output
def test_run_same_as_python_api(isolated_cli, input_file):
"""Test that running kat script via CLI same as calling :meth:`finesse.script.parse_file`."""
cli_result = isolated_cli.invoke(run, [input_file.name, "--no-plot"])
cli_result = isolated_cli.invoke(run, [input_file, "--no-plot"])
api_model = parse_file(input_file.name)
api_model = parse_file(input_file)
api_solution = api_model.run()
assert str(api_solution) in sanitized_output(cli_result)
......@@ -19,14 +19,14 @@ def test_run_same_as_python_api(isolated_cli, input_file):
def test_trace_flag(isolated_cli, input_file):
"""Test the --trace run flag."""
cli_result = isolated_cli.invoke(run, [input_file.name, "--no-plot", "--trace"])
cli_result = isolated_cli.invoke(run, [input_file, "--no-plot", "--trace"])
assert "Trace:" in sanitized_output(cli_result)
assert cli_result.exit_code == 0
def test_no_trace_flag(isolated_cli, input_file):
"""Test the --trace run flag."""
cli_result = isolated_cli.invoke(run, [input_file.name, "--no-plot", "--no-trace"])
cli_result = isolated_cli.invoke(run, [input_file, "--no-plot", "--no-trace"])
assert "Trace:" not in sanitized_output(cli_result)
assert cli_result.exit_code == 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment