From 9e9cb010cd83ad3f2074a516591d9156c68fb6cf Mon Sep 17 00:00:00 2001 From: Adrian Schlatter <10478149+adrianschlatter@users.noreply.github.com> Date: Fri, 15 Sep 2023 23:09:40 +0200 Subject: [PATCH] unittest.main() run unittest.main() if called as __main__ closes issue #14 --- tests/test_codec_common.py | 7 +++++++ tests/test_datamatrix.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/tests/test_codec_common.py b/tests/test_codec_common.py index 8fa80cc..30e9979 100644 --- a/tests/test_codec_common.py +++ b/tests/test_codec_common.py @@ -27,3 +27,10 @@ def test_unpack_invalid_words(self): words = 3 * b'\x00' # length not even with self.assertRaises(ValueError): codec_common.unpack_words(words) + + +if __name__ == '__main__': + # This enables running the unit tests by running this script which is + # much more convenient than 'python setup.py test' while developing tests. + # Note: package-under-test needs to be in python-path + unittest.main() diff --git a/tests/test_datamatrix.py b/tests/test_datamatrix.py index 03bf77b..5f28a3f 100644 --- a/tests/test_datamatrix.py +++ b/tests/test_datamatrix.py @@ -123,3 +123,10 @@ def test_random_messages(self): msg = ''.join(random.choices(ASCII, k=n)) datamatrix = put.DataMatrix(msg) self.assertTrue(len(datamatrix.matrix) > 0) + + +if __name__ == '__main__': + # This enables running the unit tests by running this script which is + # much more convenient than 'python setup.py test' while developing tests. + # Note: package-under-test needs to be in python-path + unittest.main()