From d2b2a54a724db89447027e44ecb8f9bbed72cb83 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 29 Apr 2018 22:55:26 +0200 Subject: MAT2's cli now uses meaningful return codes - Simplify the multiprocessing by using a Pool - Use some functional (♥) constructions to exit with a return code - Add some tests to prove that we're doing things that are working correctly --- tests/test_climat2.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 0536646..bc4a175 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -16,6 +16,22 @@ class TestHelp(unittest.TestCase): self.assertIn(b'usage: main.py [-h] [-c] [-l] [-s] [-L] [files [files ...]]', stdout) +class TestReturnValue(unittest.TestCase): + def test_nonzero(self): + ret = subprocess.call(['./main.py', './main.py'], stdout=subprocess.DEVNULL) + self.assertEqual(255, ret) + + ret = subprocess.call(['./main.py', '--whololo'], stderr=subprocess.DEVNULL) + self.assertEqual(2, ret) + + def test_zero(self): + ret = subprocess.call(['./main.py'], stdout=subprocess.DEVNULL) + self.assertEqual(0, ret) + + ret = subprocess.call(['./main.py', '--show', './main.py'], stdout=subprocess.DEVNULL) + self.assertEqual(0, ret) + + class TestCleanMeta(unittest.TestCase): def test_jpg(self): shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') -- cgit v1.3