diff --git a/tests/core/test_run_system.py b/tests/core/test_run_system.py index 8bebfa99db67a8764d1ce007a6d8d26ef688a7e7..060496a95dde11ce746258c47f71f64bb0354e24 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 a10e44dbe42b6315cddd3e20608b5c2a299a6f25..a01d1ad6491cb06d45bea9e13c8c956325ed788a 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 728e1fa1da9c1934941c14dc36c9c4f2e5525b9d..79fda3743e76e0fcbd9473ac00c23337a8049311 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 2b87c8f3f686e55807e7782fab5cf3d9703a37d6..1cb113dd6d98b2a84e8dcc97e19a3eaf1abd4d2c 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 fa53c93e7d1294b116b360ef9913fead76e6cf5b..187ecd9992ec44cd16ec51d53e9b965cdbc62797 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 ############################################################