From 7f2640ac64d516b7a0f8498edff1127880be32aa Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Thu, 3 Sep 2020 00:22:52 +0100
Subject: [PATCH] collecting the tests into 1 main function

---
 tests/core/test_run_system.py  | 11 +++--
 tests/function_tests.py        |  8 ++--
 tests/main.py                  |  7 ++-
 tests/population/grid_tests.py | 88 +++++++++++++++++-----------------
 tests/python_API_test.py       |  1 -
 5 files changed, 61 insertions(+), 54 deletions(-)

diff --git a/tests/core/test_run_system.py b/tests/core/test_run_system.py
index 8bebfa99d..060496a95 100644
--- a/tests/core/test_run_system.py
+++ b/tests/core/test_run_system.py
@@ -1,6 +1,4 @@
 import binary_c_python_api
-
-
 import textwrap
 
 
@@ -25,9 +23,12 @@ def test_run_system():
 
     output = binary_c_python_api.run_system(argstring=argstring)
 
-    print("function: test_run_system")
-    print("Binary_c output:")
-    print(textwrap.indent(output, "\t"))
+    # print("function: test_run_system")
+    # print("Binary_c output:")
+    # print(textwrap.indent(output, "\t"))
+
+    assert "SINGLE_STAR_LIFETIME" in output, "Run system not working properly"
+
 
 ####
 if __name__ == "__main__":
diff --git a/tests/function_tests.py b/tests/function_tests.py
index a10e44dbe..a01d1ad64 100644
--- a/tests/function_tests.py
+++ b/tests/function_tests.py
@@ -23,8 +23,6 @@ def test_get_help_super():
     assert 'algorithms' in get_help_super_keys, "missing section"
     assert 'misc' in get_help_super_keys, "missing section"
 
-    print(get_help_super_output.keys())
-
 def test_get_help_all():
     """
     Function to test the get_help_all function
@@ -48,7 +46,11 @@ def test_get_help():
 
     assert get_help("M_1", print_help=False)['parameter_name'] == 'M_1', "get_help('M_1') should return the correct parameter name"
 
-if __name__ == "__main__":
+def test_all():
     test_get_help()
     test_get_help_all()
     test_get_help_super()
+
+
+if __name__ == "__main__":
+    test_all()
\ No newline at end of file
diff --git a/tests/main.py b/tests/main.py
index 728e1fa1d..79fda3743 100644
--- a/tests/main.py
+++ b/tests/main.py
@@ -1 +1,6 @@
-# Main file for the tests. This file imports all the combined_test functions from all files.
\ No newline at end of file
+# 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
+
+test_all_grid_tests()
+test_all_function_tests()
\ No newline at end of file
diff --git a/tests/population/grid_tests.py b/tests/population/grid_tests.py
index 2b87c8f3f..1cb113dd6 100644
--- a/tests/population/grid_tests.py
+++ b/tests/population/grid_tests.py
@@ -162,8 +162,6 @@ def test_C_auto_logging_population():
 
     output = test_pop.evolve_single()
 
-    print(output.splitlines()[0].split())
-
     first_line = output.splitlines()[0].split()
 
     assert first_line[0] == "MY_HEADER_LINE" , "Failed to set the custom logging correctly"
@@ -266,21 +264,23 @@ def test_parse_function_population():
     assert first_line_split[2] == 'probability', "Output header not created correctly"
     assert len(output) > 1, "File doesn't seem to contain any real data"
 
+def test_all():
+    test_setup_population()
+    test_set_value_population()
+    test_set_argline_output_population()
+    test_version_info_dict_population()
+    test_settings_output_population()
+    test_all_info_population()
+    test_evolve_single_system_population()
+    test_C_auto_logging_population()
+    test_C_logging_code_population()
+    test_parse_function_population()
+
 if __name__ == "__main__":
-    # test_setup_population()
-    # test_set_value_population()
-    # test_set_argline_output_population()
-    # test_version_info_dict_population()
-    # test_settings_output_population()
-    # test_all_info_population()
-    # test_evolve_single_system_population()
-    # test_C_auto_logging_population()
-    # test_C_logging_code_population()
-    # test_parse_function_population()
+    test_all()
     print('yo')
 
-quit()
-
+# quit()
 # print(len(test_pop.return_binary_c_defaults()))
 # print('\n\n')
 # print(len(test_pop.cleanup_defaults()))
@@ -366,41 +366,41 @@ quit()
 
 # ###
 # testing population:
-test_pop.set(
-    verbose=1, amt_cores=2, binary=0,
-)
+# test_pop.set(
+#     verbose=1, amt_cores=2, binary=0,
+# )
 
 
-resolution = {"M_1": 10, "per": 10}
+# resolution = {"M_1": 10, "per": 10}
 
-test_pop.add_grid_variable(
-    name="M_1",
-    longname="log primary mass",
-    valuerange=[10, 100],
-    resolution="{}".format(resolution["M_1"]),
-    spacingfunc="const(10, 100, {})".format(resolution["M_1"]),
-    # precode="M_1=math.exp(lnm1)",
-    probdist="flat(M_1)",
-    # probdist='self.custom_options["extra_prob_function"](M_1)',
-    dphasevol="dM_1",
-    parameter_name="M_1",
-)
+# test_pop.add_grid_variable(
+#     name="M_1",
+#     longname="log primary mass",
+#     valuerange=[10, 100],
+#     resolution="{}".format(resolution["M_1"]),
+#     spacingfunc="const(10, 100, {})".format(resolution["M_1"]),
+#     # precode="M_1=math.exp(lnm1)",
+#     probdist="flat(M_1)",
+#     # probdist='self.custom_options["extra_prob_function"](M_1)',
+#     dphasevol="dM_1",
+#     parameter_name="M_1",
+# )
 
-### Grid generating test.
-test_pop.add_grid_variable(
-    name="period",
-    longname="period",
-    valuerange=["M_1", 20],
-    resolution="{}".format(resolution["per"]),
-    spacingfunc="np.linspace(1, 10, {})".format(resolution["per"]),
-    precode="orbital_period = period**2",
-    probdist="flat(orbital_period)",
-    parameter_name="orbital_period",
-    dphasevol="dper",
-    condition='self.grid_options["binary"]==0',
-)
+# ### Grid generating test.
+# test_pop.add_grid_variable(
+#     name="period",
+#     longname="period",
+#     valuerange=["M_1", 20],
+#     resolution="{}".format(resolution["per"]),
+#     spacingfunc="np.linspace(1, 10, {})".format(resolution["per"]),
+#     precode="orbital_period = period**2",
+#     probdist="flat(orbital_period)",
+#     parameter_name="orbital_period",
+#     dphasevol="dper",
+#     condition='self.grid_options["binary"]==0',
+# )
 
-test_pop.set(verbose=1, amt_cores=2, binary=0, evolution_type="linear")
+# test_pop.set(verbose=1, amt_cores=2, binary=0, evolution_type="linear")
 
 
 # test_pop.evolve_population()
diff --git a/tests/python_API_test.py b/tests/python_API_test.py
index fa53c93e7..187ecd999 100755
--- a/tests/python_API_test.py
+++ b/tests/python_API_test.py
@@ -14,7 +14,6 @@ import textwrap
 
 ############################################################
 # Test script for the api functions
-# TODO: Add asserts to these functions and use em as
 # unittests
 ############################################################
 
-- 
GitLab