diff --git a/binarycpython/tests/main.py b/binarycpython/tests/main.py index 20b1a1fdefb05c5aa426367c2aab3a4289f9b33d..db49ca2d8553f87884184199395aa0a657fb12b4 100644 --- a/binarycpython/tests/main.py +++ b/binarycpython/tests/main.py @@ -1,6 +1,10 @@ # Main file for the tests. This file imports all the combined_test functions from all files. -from population.grid_tests import test_all as test_all_grid_tests -from function_tests import test_all as test_all_function_tests +import unittest -test_all_grid_tests() -test_all_function_tests() +from test_c_bindings import * +from test_functions import * + + + +if __name__ == '__main__': + unittest.main() diff --git a/binarycpython/tests/test_c_bindings.py b/binarycpython/tests/test_c_bindings.py index 23efdce5a4463f91013ecad586a0c853b94014d9..5e9b9c3976a09f6157c9c4cd3029c2b96ae4310c 100644 --- a/binarycpython/tests/test_c_bindings.py +++ b/binarycpython/tests/test_c_bindings.py @@ -470,5 +470,6 @@ def all(): # # test_combine_with_empty_json() # all() # print("Done") + if __name__ == '__main__': unittest.main() diff --git a/binarycpython/tests/test_functions.py b/binarycpython/tests/test_functions.py index 150e337e2e4583ae8974716d287f3f6abc0e74b9..7d5430a189de28c520fb0a40e9cd0832e0bc8a20 100644 --- a/binarycpython/tests/test_functions.py +++ b/binarycpython/tests/test_functions.py @@ -1,52 +1,61 @@ +import unittest from binarycpython.utils.functions import * ############################# # Script that contains unit tests for functions from the binarycpython.utils.functions file -def test_get_help_super(): +class test_get_help_super(unittest.TestCase): """ - Function to test the get_help_super function + Unit test for get_help_super """ - get_help_super_output = get_help_super() - get_help_super_keys = get_help_super_output.keys() + def test_all_output(self): + """ + Function to test the get_help_super function + """ - assert "stars" in get_help_super_keys, "missing section" - assert "binary" in get_help_super_keys, "missing section" - assert "nucsyn" in get_help_super_keys, "missing section" - assert "output" in get_help_super_keys, "missing section" - assert "i/o" in get_help_super_keys, "missing section" - assert "algorithms" in get_help_super_keys, "missing section" - assert "misc" in get_help_super_keys, "missing section" + get_help_super_output = get_help_super() + get_help_super_keys = get_help_super_output.keys() + self.assertIn("stars", get_help_super_keys, "missing section") + self.assertIn("binary", get_help_super_keys, "missing section") + self.assertIn("nucsyn", get_help_super_keys, "missing section") + self.assertIn("output", get_help_super_keys, "missing section") + self.assertIn("i/o", get_help_super_keys, "missing section") + self.assertIn("algorithms", get_help_super_keys, "missing section") + self.assertIn("misc", get_help_super_keys, "missing section") -def test_get_help_all(): +class test_get_help_all(unittest.TestCase): """ - Function to test the get_help_all function + Unit test for get_help_all """ - get_help_all_output = get_help_all(print_help=False) - get_help_all_keys = get_help_all_output.keys() + def test_all_output(self): + """ + Function to test the get_help_all function + """ - assert "stars" in get_help_all_keys, "missing section" - assert "binary" in get_help_all_keys, "missing section" - assert "nucsyn" in get_help_all_keys, "missing section" - assert "output" in get_help_all_keys, "missing section" - assert "i/o" in get_help_all_keys, "missing section" - assert "algorithms" in get_help_all_keys, "missing section" - assert "misc" in get_help_all_keys, "missing section" + get_help_all_output = get_help_all(print_help=False) + get_help_all_keys = get_help_all_output.keys() -def test_get_help(): - """ - Function to test the get_help function - """ + self.assertIn("stars", get_help_all_keys, "missing section") + self.assertIn("binary", get_help_all_keys, "missing section") + self.assertIn("nucsyn", get_help_all_keys, "missing section") + self.assertIn("output", get_help_all_keys, "missing section") + self.assertIn("i/o", get_help_all_keys, "missing section") + self.assertIn("algorithms", get_help_all_keys, "missing section") + self.assertIn("misc", get_help_all_keys, "missing section") + - assert ( - get_help("M_1", print_help=False)["parameter_name"] == "M_1" - ), "get_help('M_1') should return the correct parameter name" +class test_get_help(unittest.TestCase): + def test_input(self): + """ + Function to test the get_help function + """ + self.assertEqual(get_help("M_1", print_help=False)["parameter_name"], "M_1", msg="get_help('M_1') should return the correct parameter name") def all(): test_get_help() @@ -54,5 +63,5 @@ def all(): test_get_help_super() -if __name__ == "__main__": - all() +if __name__ == '__main__': + unittest.main() diff --git a/src/binary_c_python.c b/src/binary_c_python.c index 97547ef2cad199d70568043ef6738c5d8399d993..6494cdb66ffdd21b6919044e42942e6817bdd34b 100644 --- a/src/binary_c_python.c +++ b/src/binary_c_python.c @@ -216,6 +216,8 @@ static PyObject* binary_c_run_system(PyObject *self, PyObject *args, PyObject *k fprintf(stderr, "Error (in function: binary_c_run_system): %s\n", error_buffer); + printf("Error (in function: binary_c_run_system): %s\n", + error_buffer); } Safe_free(buffer);