Skip to content

Commit

Permalink
Prevent tests breaking environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed May 22, 2024
1 parent 8d1af0b commit 79519a8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/unit_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ def test_cli_sets_beamline_environment_variable(runner: CliRunner):
assert os.environ["BEAMLINE"] == EXAMPLE_BEAMLINE


# We need to mock the environment because the CLI edits it and this could break other
# tests
@patch.dict(os.environ, clear=True)
def test_cli_connect(runner: CliRunner):
result = _mock_connect(EXAMPLE_BEAMLINE, runner=runner)
assert result.stdout.startswith("3 devices connected")


# We need to mock the environment because the CLI edits it and this could break other
# tests
@patch.dict(os.environ, clear=True)
def test_cli_connect_in_sim_mode(runner: CliRunner):
result = _mock_connect("-s", EXAMPLE_BEAMLINE, runner=runner)
assert result.stdout.startswith("3 devices connected (sim mode)")
Expand Down

0 comments on commit 79519a8

Please sign in to comment.