diff options
| -rw-r--r-- | test/clitest.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/clitest.py b/test/clitest.py index 3b09c62..ccac675 100644 --- a/test/clitest.py +++ b/test/clitest.py | |||
| @@ -139,6 +139,29 @@ class TestUnsupported(test.MATTest): | |||
| 139 | '\n- libtest.py\n- test.py\n- clitest.py\n' | 139 | '\n- libtest.py\n- test.py\n- clitest.py\n' |
| 140 | in str(stdout)) | 140 | in str(stdout)) |
| 141 | 141 | ||
| 142 | class TestHelp(test.MATTest): | ||
| 143 | """ Test the different ways to trigger help """ | ||
| 144 | def test_dash_h(self): | ||
| 145 | """ test help invocation with `-h` and `--help` """ | ||
| 146 | proc = subprocess.Popen([MAT_PATH, '-h'], stdout=subprocess.PIPE) | ||
| 147 | stdout, _ = proc.communicate() | ||
| 148 | self.assertTrue('show this help message and exit' in stdout) | ||
| 149 | |||
| 150 | proc = subprocess.Popen([MAT_PATH, '--help'], stdout=subprocess.PIPE) | ||
| 151 | stdout, _ = proc.communicate() | ||
| 152 | self.assertTrue('show this help message and exit' in stdout) | ||
| 153 | |||
| 154 | def test_no_argument(self): | ||
| 155 | """ test help invocation when no argument is provided """ | ||
| 156 | proc = subprocess.Popen([MAT_PATH], stdout=subprocess.PIPE) | ||
| 157 | stdout, _ = proc.communicate() | ||
| 158 | self.assertTrue('show this help message and exit' in stdout) | ||
| 159 | |||
| 160 | def test_wrong_argument(self): | ||
| 161 | """ Test MAT's behaviour on wrong argument """ | ||
| 162 | proc = subprocess.Popen([MAT_PATH, '--obviously-wrong-argument'], stderr=subprocess.PIPE) | ||
| 163 | _, stderr = proc.communicate() | ||
| 164 | self.assertTrue(('usage: mat [-h]' and ' error: unrecognized arguments:') in stderr) | ||
| 142 | 165 | ||
| 143 | def get_tests(): | 166 | def get_tests(): |
| 144 | """ Return every clitests""" | 167 | """ Return every clitests""" |
| @@ -148,4 +171,5 @@ def get_tests(): | |||
| 148 | suite.addTest(unittest.makeSuite(TestisCleancli)) | 171 | suite.addTest(unittest.makeSuite(TestisCleancli)) |
| 149 | suite.addTest(unittest.makeSuite(TestUnsupported)) | 172 | suite.addTest(unittest.makeSuite(TestUnsupported)) |
| 150 | suite.addTest(unittest.makeSuite(TestFileAttributes)) | 173 | suite.addTest(unittest.makeSuite(TestFileAttributes)) |
| 174 | suite.addTest(unittest.makeSuite(TestHelp)) | ||
| 151 | return suite | 175 | return suite |
