Skip to content
Myr

:white_check_mark: Fix tests using binary config files

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sebastián Ramírez · committed by Sebastián Ramírez · parent 2af83b0 · Browse files · 7 files+22 added−28 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+22 added−28 removed

  • tests:+22 added−28 removed

7 files+22 added−28 removed

modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py+2 added-3 removed
9 unmodified lines
1011app = typer.Typer()12app.command()(mod.main)1314config_file = Path("./config.txt")141617def test_main():15def test_main(tmpdir):16 config_file = Path(tmpdir) / "config.txt"17 config_file.write_text("some settings\nsome more settings")18 result = runner.invoke(app, ["--config", f"{config_file}"])19 config_file.unlink()20 assert result.exit_code == 0
12 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py+2 added-3 removed
9 unmodified lines
1011app = typer.Typer()12app.command()(mod.main)1314config_file = Path("./config.txt")141617def test_main():15def test_main(tmpdir):16 config_file = Path(tmpdir) / "config.txt"17 if config_file.exists(): # pragma no cover18 config_file.unlink()19 result = runner.invoke(app, ["--config", f"{config_file}"])20 text = config_file.read_text()
14 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py+2 added-3 removed
9 unmodified lines
1011app = typer.Typer()12app.command()(mod.main)1314binary_file = Path("./config.txt")141617def test_main():15def test_main(tmpdir):16 binary_file = Path(tmpdir) / "config.txt"17 binary_file.write_bytes(b"la cig\xc3\xbce\xc3\xb1a trae al ni\xc3\xb1o")18 result = runner.invoke(app, ["--file", f"{binary_file}"])19 binary_file.unlink()20 assert result.exit_code == 0
11 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py+2 added-3 removed
9 unmodified lines
1011app = typer.Typer()12app.command()(mod.main)1314binary_file = Path("./config.txt")141617def test_main():15def test_main(tmpdir):16 binary_file = Path(tmpdir) / "config.txt"17 if binary_file.exists(): # pragma no cover18 binary_file.unlink()19 result = runner.invoke(app, ["--file", f"{binary_file}"])20 text = binary_file.read_text()
15 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py+2 added-3 removed
9 unmodified lines
1011app = typer.Typer()12app.command()(mod.main)1314config_file = Path("./config.txt")141617def test_main():15def test_main(tmpdir):16 config_file = Path(tmpdir) / "config.txt"17 if config_file.exists(): # pragma no cover18 config_file.unlink()19 config_file.write_text("")20 result = runner.invoke(app, ["--config", f"{config_file}"])
17 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py+6 added-5 removed
9 unmodified lines
1011app = typer.Typer()12app.command()(mod.main)1314config_file = Path("./config.txt")141617def test_no_path():15def test_no_path(tmpdir):16 Path(tmpdir) / "config.txt"17 result = runner.invoke(app)18 assert result.exit_code == 119 assert "No config file" in result.output20 assert "Aborted!" in result.output212224def test_not_exists():23def test_not_exists(tmpdir):24 config_file = Path(tmpdir) / "config.txt"25 if config_file.exists(): # pragma no cover26 config_file.unlink()27 result = runner.invoke(app, ["--config", f"{config_file}"])28 assert result.exit_code == 029 assert "The config doesn't exist" in result.output303132def test_exists():32def test_exists(tmpdir):33 config_file = Path(tmpdir) / "config.txt"34 config_file.write_text("some settings")35 result = runner.invoke(app, ["--config", f"{config_file}"])36 config_file.unlink()37 assert result.exit_code == 0
17 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py+6 added-8 removed
9 unmodified lines
1011app = typer.Typer()12app.command()(mod.main)1314config_file = Path("./config.txt")141617def test_not_exists():15def test_not_exists(tmpdir):16 config_file = Path(tmpdir) / "config.txt"17 if config_file.exists(): # pragma no cover18 config_file.unlink()19 result = runner.invoke(app, ["--config", f"{config_file}"])20 assert result.exit_code != 022 assert (23 'Error: Invalid value for "--config": File "config.txt" does not exist.'24 in result.output25 )21 assert 'Error: Invalid value for "--config": File' in result.output22 assert "does not exist" in result.output232428def test_exists():25def test_exists(tmpdir):26 config_file = Path(tmpdir) / "config.txt"27 config_file.write_text("some settings")28 result = runner.invoke(app, ["--config", f"{config_file}"])29 config_file.unlink()30 assert result.exit_code == 0
20 unmodified lines