File tree 2 files changed +43
-1
lines changed
2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -38,5 +38,5 @@ def main(argv=None):
38
38
)
39
39
40
40
41
- if __name__ == "__main__" :
41
+ if __name__ == "__main__" : # pragma: nocover
42
42
main ()
Original file line number Diff line number Diff line change
1
+ import re
2
+ import sys
3
+
4
+ import pytest
5
+
6
+ from Magics .__main__ import main , selfcheck
7
+
8
+
9
+ def test_selfcheck (capsys ):
10
+ selfcheck ()
11
+
12
+ stdout , stderr = capsys .readouterr ()
13
+
14
+ assert "Found:" in stdout
15
+ assert "Library:" in stdout
16
+ assert "Magics home:" in stdout
17
+ assert "Your system is ready." in stdout
18
+
19
+ assert "You are using an old version of magics" not in stdout
20
+
21
+
22
+ def test_main_success (capsys ):
23
+ sys .argv = ["program" , "selfcheck" ]
24
+ main ()
25
+ stdout , stderr = capsys .readouterr ()
26
+ assert "Your system is ready." in stdout
27
+
28
+
29
+ def test_main_failure_no_command (capsys ):
30
+ sys .argv = ["program" ]
31
+ with pytest .raises (SystemExit ) as ex :
32
+ main ()
33
+ ex .match ("2" )
34
+ stdout , stderr = capsys .readouterr ()
35
+ assert "program: error: the following arguments are required: command" in stderr
36
+
37
+
38
+ def test_main_failure_unknown_command (capsys ):
39
+ sys .argv = ["program" , "foobar" ]
40
+ with pytest .raises (RuntimeError ) as ex :
41
+ main ()
42
+ ex .match (re .escape ("Command not recognised 'foobar'. See usage with --help." ))
You can’t perform that action at this time.
0 commit comments