Commit d569dc90 authored by Gregory Ashton's avatar Gregory Ashton

Merge branch 'make-tests-more-robust' into 'master'

Make tests more robust

See merge request GregAshton/PyFstat!21
parents e976b57c 367e4a02
...@@ -31,11 +31,8 @@ def _optional_import(modulename, shorthand=None): ...@@ -31,11 +31,8 @@ def _optional_import(modulename, shorthand=None):
logging.debug("Successfully imported module %s%s." % (modulename, shorthandbit)) logging.debug("Successfully imported module %s%s." % (modulename, shorthandbit))
success = True success = True
except ImportError as e: except ImportError as e:
if e.message == "No module named " + modulename: logging.debug("Failed to import module {:s}.".format(modulename))
logging.debug("No module {:s} found.".format(modulename)) success = False
success = False
else:
raise
return success return success
......
...@@ -31,6 +31,5 @@ setup( ...@@ -31,6 +31,5 @@ setup(
"bashplotlib", "bashplotlib",
"peakutils", "peakutils",
"pathos", "pathos",
"pycuda",
], ],
) )
...@@ -5,7 +5,7 @@ import shutil ...@@ -5,7 +5,7 @@ import shutil
import pyfstat import pyfstat
import lalpulsar import lalpulsar
import logging import logging
import time
class Test(unittest.TestCase): class Test(unittest.TestCase):
outdir = "TestData" outdir = "TestData"
...@@ -85,6 +85,7 @@ class Writer(Test): ...@@ -85,6 +85,7 @@ class Writer(Test):
Writer.run_makefakedata() Writer.run_makefakedata()
time_second = os.path.getmtime(Writer.sftfilepath) time_second = os.path.getmtime(Writer.sftfilepath)
self.assertTrue(time_first == time_second) self.assertTrue(time_first == time_second)
time.sleep(1) # make sure timestamp is actually different!
os.system("touch {}".format(Writer.config_file_name)) os.system("touch {}".format(Writer.config_file_name))
Writer.run_makefakedata() Writer.run_makefakedata()
time_third = os.path.getmtime(Writer.sftfilepath) time_third = os.path.getmtime(Writer.sftfilepath)
...@@ -550,12 +551,8 @@ class GridSearch(Test): ...@@ -550,12 +551,8 @@ class GridSearch(Test):
tref=self.tref, tref=self.tref,
Lambda0=[30, 0, 0, 0], Lambda0=[30, 0, 0, 0],
) )
search.run() fig, axes = search.run(save=False)
self.assertTrue( self.assertTrue(fig is not None)
os.path.isfile(
"{}/{}_slice_projection.png".format(search.outdir, search.label)
)
)
def test_glitch_grid_search(self): def test_glitch_grid_search(self):
search = pyfstat.GridGlitchSearch( search = pyfstat.GridGlitchSearch(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment