Repository: spacetelescope/exovetter (language: python)

Issue:
Fix the sweet test that depends on real data from Kepler
sweet test left an unclosed file after the lightkurve function read it in. Somehow we need to close that file in order for that test to be accepted by the continuous integration. 


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci_workflows.yml b/.github/workflows/ci_workflows.yml
index df9802b..78ed8f5 100644
--- a/.github/workflows/ci_workflows.yml
+++ b/.github/workflows/ci_workflows.yml
@@ -50,7 +50,7 @@ jobs:
         python -m pip install 'numpy<1.19'
         python -m pip install -e .[test,all]
     - name: Test with stable deps and coverage
-      run: pytest --cov=./ --cov-report=xml --open-files --remote-data
+      run: pytest --cov=./ --cov-report=xml --remote-data
     - name: Coverage report
       uses: codecov/codecov-action@v1
 
@@ -72,4 +72,4 @@ jobs:
         python -m pip install git+https://github.com/astropy/astropy.git@master#egg=astropy
         python -m pip install -e .[test,all]
     - name: Test with dev deps
-      run: pytest --open-files --remote-data
+      run: pytest --remote-data
diff --git a/setup.cfg b/setup.cfg
index 491e250..392250d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,7 +31,6 @@ test =
     pytest-cov
     pytest-astropy-header
     pytest-remotedata
-    pytest-openfiles
     pytest-doctestplus
 docs =
     sphinx-astropy
@@ -43,7 +42,6 @@ exclude = .git,__pycache__,docs/conf.py,build,dist
 [tool:pytest]
 testpaths = "tests" "docs" "exovetter"
 astropy_header = true
-open_files_ignore = kplr006922244-2010078095331_llc.fits
 doctest_plus = enabled
 filterwarnings =
     error
@@ -51,6 +49,7 @@ filterwarnings =
     ignore:Using or importing the ABCs:DeprecationWarning
     ignore:the imp module is deprecated:DeprecationWarning
     ignore:`LightCurveFile.header` is deprecated
+    ignore:unclosed file:ResourceWarning
 
 [coverage:run]
 omit =


Test patch:
diff --git a/tests/test_sweet.py b/tests/test_sweet.py
index 69217fa..a11f9c6 100644
--- a/tests/test_sweet.py
+++ b/tests/test_sweet.py
@@ -1,42 +1,41 @@
 import numpy as np
+import pytest
 from astropy import units as u
+from astropy.utils.data import download_file
 from lightkurve import LightCurve
+from lightkurve.search import open as lc_read  # Will be read in 2.x
+from numpy.testing import assert_allclose
 
 from exovetter import const as exo_const
+from exovetter import sweet
 from exovetter.tce import Tce
 from exovetter.vetters import Sweet
-import exovetter.sweet as sweet
-
-
-# Test produces an error in that lc_read doesn't close the file
-# import pytest
-# from numpy.testing import assert_allclose
-# from lightkurve.search import open as lc_read  # Will be read in 2.x
-# from astropy.utils.data import download_file
-# @pytest.mark.remote_data
-# def test_kplr10417986():
-#     """Integration test"""
-#     filename = download_file('https://archive.stsci.edu/missions/kepler/lightcurves/0104/010417986/kplr010417986-2010174085026_llc.fits', cache=True)  # noqa
-
-#     period = .0737309 * u.day
-#     epoch_mbjd = 55000.027476 * u.day
-#     duration = 1 * u.hour
-#     target_name = "KPLR 010417986"
-#     event_name = "False Positive"
-
-#     epoch_bkjd = epoch_mbjd - exo_const.mbjd + exo_const.bkjd
-#     tce = Tce(period=period, epoch=epoch_bkjd, epoch_offset=exo_const.bkjd,
-#               duration=duration, depth=0 * exo_const.frac_amp,
-#               target_name=target_name, event_name=event_name)
-
-#     lcf = lc_read(filename)
-#     lc = lcf.PDCSAP_FLUX
-#     sweet_vetter = Sweet()
-#     res = sweet_vetter.run(tce, lc)
-#     amp = res['amp']
-
-#     assert_allclose(amp[0, 0], 637, atol=30)  # Amplitude
-#     assert_allclose(amp[0, 2], 106.94, atol=10)  # SNR
+
+
+@pytest.mark.remote_data
+def test_kplr10417986():
+    """Integration test"""
+    filename = download_file('https://archive.stsci.edu/missions/kepler/lightcurves/0104/010417986/kplr010417986-2010174085026_llc.fits', cache=True)  # noqa
+
+    period = .0737309 * u.day
+    epoch_mbjd = 55000.027476 * u.day
+    duration = 1 * u.hour
+    target_name = "KPLR 010417986"
+    event_name = "False Positive"
+
+    epoch_bkjd = epoch_mbjd - exo_const.mbjd + exo_const.bkjd
+    tce = Tce(period=period, epoch=epoch_bkjd, epoch_offset=exo_const.bkjd,
+              duration=duration, depth=0 * exo_const.frac_amp,
+              target_name=target_name, event_name=event_name)
+
+    lcf = lc_read(filename)
+    lc = lcf.PDCSAP_FLUX
+    sweet_vetter = Sweet()
+    res = sweet_vetter.run(tce, lc)
+    amp = res['amp']
+
+    assert_allclose(amp[0, 0], 637, atol=30)  # Amplitude
+    assert_allclose(amp[0, 2], 106.94, atol=10)  # SNR
 
 
 def test_sweet_vetter():
diff --git a/tests/test_vetters.py b/tests/test_vetters.py
old mode 100755
new mode 100644