Repository: UCBerkeleySETI/blimpy (language: python)

Issue:
Some regression tests need some re-work
Some tests were not doing what they are supposed to do.
Some tests were insufficient.
Some tests were dropiing output files all over the place.


Discussion / hints:

Fix patch:
diff --git a/setup.cfg b/setup.cfg
index ff3b8c7..7cef2f9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -6,3 +6,6 @@ description-file=README.md
 
 [global]
 no-binary = h5py
+
+[tool:pytest]
+addopts=--verbose


Test patch:
diff --git a/tests/test_bl_scrunch.py b/tests/test_bl_scrunch.py
index 86b0244..e10690c 100644
--- a/tests/test_bl_scrunch.py
+++ b/tests/test_bl_scrunch.py
@@ -8,6 +8,9 @@
 import blimpy as bl
 from tests.data import voyager_h5
 
+OUTDIR = os.path.dirname(voyager_h5) + "/"
+print("test_bl_scrunch: output directory:", OUTDIR)
+
 
 def test_scrunch():
     r"""
@@ -30,10 +33,11 @@ def test_nameless():
     """
 
     print("\n===== test_nameless BEGIN")
-    bl.bl_scrunch.bl_scrunch(voyager_h5, f_scrunch=8)
+    bl.bl_scrunch.bl_scrunch(voyager_h5, out_dir=OUTDIR, f_scrunch=8)
 
     with pytest.raises(SystemExit):
-        bl.bl_scrunch.cmd_tool()
+        args = ["-o", OUTDIR, "-n", "test.scrunched.h5", "-f", "8", "-l", "0.1"]
+        bl.bl_scrunch.cmd_tool(args)
     print("\n===== test_nameless END")
 
 
@@ -41,11 +45,11 @@ def test_cmd():
     r""" Pass in some example sets of arguments """
     # this is a malformed arg set with one giant string in the first entry
     print("\n===== test_cmd BEGIN")
-    args = [voyager_h5, "-n", "\'test.scrunched.h5\'", "-f", "8", "-l", "0.1"]
+    args = [voyager_h5, "-o", OUTDIR, "-n", "test.scrunched.h5", "-f", "8", "-l", "0.1"]
     bl.bl_scrunch.cmd_tool(args)
-    args = [voyager_h5, "-f", "8", "-l", "0.1"]
+    args = [voyager_h5, "-f", "8", "-l", "0.1", "--out_dir", OUTDIR]
     bl.bl_scrunch.cmd_tool(args)
-    args = [voyager_h5, "--mickey_mouse", "-f", "8", "-l", "0.1"]
+    args = [voyager_h5, "--mickey_mouse", "-f", "8", "-l", "0.1", "-o", OUTDIR]
     with pytest.raises(SystemExit):
         bl.bl_scrunch.cmd_tool(args)
     print("\n===== test_cmd END")
diff --git a/tests/test_fil2h5.py b/tests/test_fil2h5.py
index 5f51874..64c8cfc 100644
--- a/tests/test_fil2h5.py
+++ b/tests/test_fil2h5.py
@@ -9,6 +9,9 @@
 from tests.data import voyager_fil
 
 
+OUTDIR = os.path.dirname(voyager_fil) + "/"
+
+
 def test_fil2h5_conversion():
     """ Tests the conversion of fil files into h5 in both light and heavy modes.
     """
@@ -27,15 +30,18 @@ def test_cmd_tool():
     This is the same test file, but now through the cmd tool.
     """
     #with pytest.raises(SystemExit):
-    bl.fil2h5.cmd_tool([voyager_fil, '-n', 'cmd.h5'])
+    args = [voyager_fil, '-n', OUTDIR + 'cmd.h5']
+    bl.fil2h5.cmd_tool(args=args)
 
 def test_no_args():
     """
     The cmd tool needs to exit, mandating a file name.
     """
     with pytest.raises(SystemExit):
-        bl.fil2h5.cmd_tool()
+        bl.fil2h5.cmd_tool("")
 
 
 if __name__ == "__main__":
     test_fil2h5_conversion()
+    test_cmd_tool()
+    test_no_args()
diff --git a/tests/test_h52fil.py b/tests/test_h52fil.py
index c3abc46..c74e3d2 100644
--- a/tests/test_h52fil.py
+++ b/tests/test_h52fil.py
@@ -9,6 +9,9 @@
 from tests.data import voyager_h5
 
 
+OUTDIR = os.path.dirname(voyager_h5) + "/"
+
+
 def test_h52fil_conversion():
     """ Tests the conversion of fil files into h5 in both light and heavy modes.
     """
@@ -37,16 +40,16 @@ def test_help():
 
 def test_cmd_tool():
     """
-    This is the same large test file, but now through the cmd tool.
+    This is the same Voyager test file, but now through the cmd tool.
     """
-    bl.h52fil.cmd_tool([voyager_h5, '-n', 'cmd.fil', '-l', '.001'])
+    bl.h52fil.cmd_tool([voyager_h5, '-n', OUTDIR + 'cmd.fil', '-l', '.001'])
 
 def test_no_args():
     """
     The cmd tool needs to exit, mandating a file name.
     """
     with pytest.raises(SystemExit):
-        bl.h52fil.cmd_tool()
+        bl.h52fil.cmd_tool(['-n', OUTDIR + 'cmd.fil', '-l', '.001'])
 
 if __name__ == "__main__":
     test_h52fil_conversion()
diff --git a/tests/test_match_fits.py b/tests/test_match_fils.py
similarity index 100%
rename from tests/test_match_fits.py
rename to tests/test_match_fils.py
diff --git a/tests/test_waterfall.py b/tests/test_waterfall.py
index 98de85d..ac48615 100644
--- a/tests/test_waterfall.py
+++ b/tests/test_waterfall.py
@@ -5,6 +5,8 @@
 
 import pytest
 
+OUTDIR = os.path.dirname(voyager_h5) + "/"
+
 def test_info():
     a = bl.Waterfall(voyager_h5)
     print(a)
@@ -38,30 +40,30 @@ def test_get_freqs():
 def test_cmdline():
     from blimpy.waterfall import cmd_tool
 
-    args = [voyager_h5, '-S', '-s', 'test.png']
+    args = [voyager_h5, '-S', '-s', OUTDIR + 'test.png']
     cmd_tool(args)
 
     args = [voyager_h5, '-i']
     cmd_tool(args)
 
-    if os.path.exists('test.h5'):
-        os.remove('test.h5')
-        args = [voyager_h5, '-H', '-o', 'test.h5']
+    if os.path.exists(OUTDIR + 'test.h5'):
+        os.remove(OUTDIR + 'test.h5')
+        args = [voyager_h5, '-H', '-o', OUTDIR + 'test.h5']
         cmd_tool(args)
-        assert os.path.exists('test.h5')
-        os.remove('test.h5')
+        assert os.path.exists(OUTDIR + 'test.h5')
+        os.remove(OUTDIR + 'test.h5')
 
-    if os.path.exists('test.fil'):
-        os.remove('test.fil')
-        args = [voyager_h5, '-F', '-o', 'test.fil']
+    if os.path.exists(OUTDIR + 'test.fil'):
+        os.remove(OUTDIR + 'test.fil')
+        args = [voyager_h5, '-F', '-o', OUTDIR + 'test.fil']
         cmd_tool(args)
-        assert os.path.exists('test.fil')
-        os.remove('test.fil')
+        assert os.path.exists(OUTDIR + 'test.fil')
+        os.remove(OUTDIR + 'test.fil')
 
 def test_cmd_arguments():
     from blimpy.waterfall import cmd_tool
     
-    args = [voyager_h5, '-H', '-F', '-o', 'test.fil']
+    args = [voyager_h5, '-H', '-F', '-o', OUTDIR + 'test.fil']
     with pytest.raises(ValueError):
         cmd_tool(args)
 
diff --git a/tests/test_write_to_fil.py b/tests/test_write_to_fil.py
index 7eaec81..bfd0a7b 100644
--- a/tests/test_write_to_fil.py
+++ b/tests/test_write_to_fil.py
@@ -1,15 +1,18 @@
 """
 Very small module with one test: test_write_to_fil()
 """
+import os
 import blimpy as bl
 
 from tests.data import voyager_h5
 
+OUTDIR = os.path.dirname(voyager_h5) + "/"
+
 def test_write_to_fil():
     """ Load Voyager dataset and test plotting """
 
     a = bl.Waterfall(voyager_h5)
-    a.write_to_fil('test_out.fil')
+    a.write_to_fil(OUTDIR + 'test_out.fil')
 
 if __name__ == "__main__":
     test_write_to_fil()