diff --git a/tests/test_xfel_calibrate/conftest.py b/tests/test_xfel_calibrate/conftest.py index 739182a846b744a1c167623039f320ec5af55d88..95bc80f2e7fb0e71bbae94921df10514bc26c658 100644 --- a/tests/test_xfel_calibrate/conftest.py +++ b/tests/test_xfel_calibrate/conftest.py @@ -227,14 +227,13 @@ class CalibrateCall: if extra_args: self.args.extend(extra_args) - with mock.patch.object(sys, "argv", self.args): - with mock.patch.object(calibrate, "temp_path", str(tmp_path)): - calibrate.run() + with mock.patch.object(calibrate, "temp_path", str(tmp_path)): + calibrate.run(argv=self.args) - out, err = capsys.readouterr() + out, err = capsys.readouterr() - self.out: str = out - self.err: str = err + self.out: str = out + self.err: str = err Paths = NamedTuple( "Paths", diff --git a/tests/test_xfel_calibrate/test_cli.py b/tests/test_xfel_calibrate/test_cli.py index 8eeae450e17dd88225c6f080786f83208cdcdfec..1bb0c1a2794bfde1932f4b4702e63b18facdfa79 100644 --- a/tests/test_xfel_calibrate/test_cli.py +++ b/tests/test_xfel_calibrate/test_cli.py @@ -30,10 +30,9 @@ class TestBasicCalls: that the expected output is present in stdout """ - @mock.patch.object(sys, "argv", ["xfel-calibrate", "--help"]) def test_help(self, capsys): with pytest.raises(SystemExit): - calibrate.run() + calibrate.run(["xfel-calibrate", "--help"]) out, err = capsys.readouterr() @@ -43,10 +42,9 @@ class TestBasicCalls: assert err == "" - @mock.patch.object(sys, "argv", ["xfel-calibrate", "TEST", "-h"]) def test_help_detector(self, capsys): with pytest.raises(SystemExit): - calibrate.run() + calibrate.run(["xfel-calibrate", "TEST", "-h"]) out, err = capsys.readouterr() @@ -55,10 +53,9 @@ class TestBasicCalls: assert err == "" - @mock.patch.object(sys, "argv", ["xfel-calibrate", "TEST", "-h"]) def test_help_user_notebook(self, capsys): with pytest.raises(SystemExit): - calibrate.run() + calibrate.run(["xfel-calibrate", "TEST", "-h"]) out, err = capsys.readouterr() @@ -67,15 +64,13 @@ class TestBasicCalls: assert err == "" - @mock.patch.object(sys, "argv", ["xfel-calibrate", "TEST-RAISES-ERRORS", "--help"]) def test_help_bad_config(self): with pytest.raises(KeyError): - calibrate.run() + calibrate.run(["xfel-calibrate", "TEST-RAISES-ERRORS", "--help"]) - @mock.patch.object(sys, "argv", ["xfel-calibrate", "NotADetector", "beep", "-h"]) def test_unknown_detector(self, capsys): with pytest.raises(SystemExit) as exit_exception: - calibrate.run() + calibrate.run(["xfel-calibrate", "NotADetector", "beep", "-h"]) out, err = capsys.readouterr() @@ -85,10 +80,9 @@ class TestBasicCalls: assert err == "" - @mock.patch.object(sys, "argv", ["xfel-calibrate", "NotADetector", "-h"]) def test_unknown_detector_h(self, capsys): with pytest.raises(SystemExit) as exit_exception: - calibrate.run() + calibrate.run(["xfel-calibrate", "NotADetector", "-h"]) out, err = capsys.readouterr() @@ -98,10 +92,9 @@ class TestBasicCalls: assert err == "" - @mock.patch.object(sys, "argv", ["xfel-calibrate", "Tutorial", "TEST", "--help"]) def test_help_nb(self, capsys): with pytest.raises(SystemExit): - calibrate.run() + calibrate.run(["xfel-calibrate", "Tutorial", "TEST", "--help"]) out, err = capsys.readouterr() @@ -165,6 +158,7 @@ class TestTutorialNotebook: def test_expected_processes_called( self, + calibrate_call: CalibrateCall, fake_process_calibrate: FakeProcessCalibrate, ): process_calls = [ diff --git a/tests/test_xfel_calibrate/test_user_configs.py b/tests/test_xfel_calibrate/test_user_configs.py index 21feb55a995ec06e3deb1d71c64d6fe7abdc67cd..cbae495977b217409b64acc8c753facd63f36070 100644 --- a/tests/test_xfel_calibrate/test_user_configs.py +++ b/tests/test_xfel_calibrate/test_user_configs.py @@ -126,6 +126,7 @@ class TestUserVenv: def test_expected_processes_called( self, + calibrate_call: CalibrateCall, mock_proposal: MockProposal, fake_process_calibrate: FakeProcessCalibrate, ):