From 9c75c51ac367b36250221d863f5e03414d1d97d4 Mon Sep 17 00:00:00 2001 From: dh00601 <dh00601@surrey.ac.uk> Date: Wed, 29 Dec 2021 14:28:26 +0000 Subject: [PATCH] working on splitting the custom logging unit tests --- binarycpython/tests/main.py | 13 +++++++--- binarycpython/tests/test_custom_logging.py | 30 +++++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/binarycpython/tests/main.py b/binarycpython/tests/main.py index 94e785c88..4f5e8a783 100755 --- a/binarycpython/tests/main.py +++ b/binarycpython/tests/main.py @@ -1,8 +1,6 @@ # /usr/bin/env python """ -Main file for the tests. This file imports all the combined_test functions from all files. - -TODO: fix the imports without the wildcard +Main file for the tests. This file imports all the unit test functions from all modules except for the notebooks and for the HPC functions """ import unittest @@ -12,7 +10,14 @@ from binarycpython.tests.test_c_bindings import ( test_return_store_memaddr, TestEnsemble, ) -# from binarycpython.tests.test_custom_logging import * +from binarycpython.tests.test_custom_logging import ( + test_autogen_C_logging_code, + test_binary_c_log_code, + test_binary_c_write_log_code, + test_from_binary_c_config, + test_return_compilation_dict, + test_create_and_load_logging_function +) # from binarycpython.tests.test_distributions import * # from binarycpython.tests.test_functions import * # from binarycpython.tests.test_grid import * diff --git a/binarycpython/tests/test_custom_logging.py b/binarycpython/tests/test_custom_logging.py index d50689849..49334004d 100644 --- a/binarycpython/tests/test_custom_logging.py +++ b/binarycpython/tests/test_custom_logging.py @@ -10,9 +10,9 @@ from binarycpython.utils.functions import Capturing TMP_DIR = temp_dir("tests", "test_custom_logging") -class test_custom_logging(unittest.TestCase): +class test_autogen_C_logging_code(unittest.TestCase): """ - Unit test for the custom_logging module + Unit test class for autogen_C_logging_code """ def test_autogen_C_logging_code(self): @@ -48,6 +48,11 @@ class test_custom_logging(unittest.TestCase): output_3 = autogen_C_logging_code(input_dict_3, verbosity=1) self.assertEqual(output_3, None, msg="Output should be None") +class test_binary_c_log_code(unittest.TestCase): + """ + Unit test for binary_c_log_code + """ + def test_binary_c_log_code(self): with Capturing() as output: self._test_binary_c_log_code() @@ -72,6 +77,11 @@ class test_custom_logging(unittest.TestCase): msg="Output does not match what it should be: {}".format(test_value_2), ) +class test_binary_c_write_log_code(unittest.TestCase): + """ + Unit test for binary_c_write_log_code + """ + def test_binary_c_write_log_code(self): with Capturing() as output: self._test_binary_c_write_log_code() @@ -98,6 +108,11 @@ class test_custom_logging(unittest.TestCase): content_file = repr(f.read()) self.assertEqual(repr(input_1), content_file, msg="Contents are not similar") +class test_from_binary_c_config(unittest.TestCase): + """ + Unit test for from_binary_c_config + """ + def test_from_binary_c_config(self): with Capturing() as output: self._test_from_binary_c_config() @@ -131,6 +146,11 @@ class test_custom_logging(unittest.TestCase): msg="binary_c version doesnt match", ) +class test_return_compilation_dict(unittest.TestCase): + """ + Unit test for return_compilation_dict + """ + def test_return_compilation_dict(self): with Capturing() as output: self._test_return_compilation_dict() @@ -152,6 +172,11 @@ class test_custom_logging(unittest.TestCase): self.assertTrue("libs" in output) self.assertTrue("inc" in output) +class test_create_and_load_logging_function(unittest.TestCase): + """ + Unit test for return_compilation_dict + """ + def test_create_and_load_logging_function(self): with Capturing() as output: self._test_create_and_load_logging_function() @@ -173,6 +198,5 @@ class test_custom_logging(unittest.TestCase): msg="Name of the libcustom_logging not correct", ) - if __name__ == "__main__": unittest.main() -- GitLab