Skip to content
Snippets Groups Projects
Commit 4e6c1662 authored by David Hendriks's avatar David Hendriks
Browse files

updated test suites to handle the pycapsules

parent cbfc78ac
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,11 @@ ensemble_filters_off {8} ensemble_filter_{9} 1 probability 0.1"
return argstring
def is_capsule(o):
t = type(o)
return t.__module__ == 'builtins' and t.__name__ == 'PyCapsule'
#######################################################################################################################################################
### General run_system test
#######################################################################################################################################################
......@@ -78,6 +83,7 @@ class test_run_system(unittest.TestCase):
"""
General test if run_system works
"""
print(self.id())
m1 = 15.0 # Msun
m2 = 14.0 # Msun
......@@ -109,6 +115,7 @@ class test_run_system(unittest.TestCase):
### memaddr test
#######################################################################################################################################################
# TODO: Make some assertion tests in c
class test_return_store_memaddr(unittest.TestCase):
"""
......@@ -119,15 +126,17 @@ class test_return_store_memaddr(unittest.TestCase):
"""
Test to see if the memory adress is returned properly
"""
print(self.id())
output = _binary_c_bindings.return_store_memaddr()
# print("function: test_return_store")
# print("store memory adress:")
# print(textwrap.indent(str(output), "\t"))
self.assertTrue(isinstance(output, int))
self.assertNotEqual(output, -1, "memory adress not created properly")
self.assertTrue(is_capsule(output))
# self.assertNotEqual(
# output, 0, "memory adress seems not to have a correct value"
# )
# TODO: check if we can built in some signal for how successful this was.
_ = _binary_c_bindings.free_store_memaddr(output)
......@@ -153,18 +162,20 @@ class TestEnsemble(unittest.TestCase):
"""
Test case to check if the memory adress has been created succesfully
"""
print(self.id())
output = _binary_c_bindings.return_persistent_data_memaddr()
self.assertIsInstance(output, int, msg="memory adress has to be an integer")
self.assertNotEqual(
output, 0, "memory adress seems not to have a correct value"
)
self.assertTrue(is_capsule(output), msg="Object must be an integer")
# self.assertNotEqual(
# output, 0, "memory adress seems not to have a correct value"
# )
def test_minimal_ensemble_output(self):
"""
test_case to check if the ensemble output is correctly output
"""
print(self.id())
m1 = 2 # Msun
m2 = 0.1 # Msun
......@@ -190,6 +201,7 @@ class TestEnsemble(unittest.TestCase):
"""
test_case to check if the ensemble output is correctly output, by using defer command and freeing+outputting
"""
print(self.id())
m1 = 2 # Msun
m2 = 0.1 # Msun
......@@ -227,6 +239,7 @@ class TestEnsemble(unittest.TestCase):
"""
test_case to check if adding the ensemble outputs works. Many things should be caught by tests in the merge_dict test, but still good to test a bit here
"""
print(self.id())
m1 = 2 # Msun
m2 = 0.1 # Msun
......@@ -287,6 +300,7 @@ class TestEnsemble(unittest.TestCase):
"""
test to run 2 systems without deferring, and merging them manually. Then run 2 systems with defer and then output them.
"""
print(self.id())
m1 = 2 # Msun
m2 = 0.1 # Msun
......@@ -373,6 +387,7 @@ class TestEnsemble(unittest.TestCase):
"""
Test for merging with an empty dict
"""
print(self.id())
m1 = 2 # Msun
m2 = 0.1 # Msun
......@@ -398,6 +413,7 @@ class TestEnsemble(unittest.TestCase):
Function to just output the whole ensemble
TODO: put this one back
"""
print(self.id())
m1 = 2 # Msun
m2 = 0.1 # Msun
......
......@@ -465,7 +465,7 @@ class test_grid_evolve(unittest.TestCase):
test_pop_evolve_1_thread = Population()
test_pop_evolve_1_thread.set(
amt_cores=1, verbosity=1, M_2=1, orbital_period=100000
amt_cores=1, verbosity=0, M_2=1, orbital_period=100000
)
resolution = {"M_1": 10}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment