import pytest
from astropy.io import fits as pyfits
from astropy.utils.data import get_pkg_data_filename
from astropy.utils.misc import NumpyRNGContext
from ..keptrial import keptrial
from ..kepio import delete

# fake light curve with transits of period = 2.02 days
# and duration 0.18 days
fake_lc = get_pkg_data_filename("data/golden-lc.fits")

def test_keptrial():
    with NumpyRNGContext(123):
        keptrial(fake_lc, "keptrial.fits", datacol='SAP_FLUX', errcol='SAP_FLUX_ERR',
                 fmin=0.4, fmax=0.67, ntrials=50, nfreq=10, overwrite=True)
        f = pyfits.open("keptrial.fits")
        assert abs(f[3].header['PERIOD'] - 2.02) < 0.1
        delete("keptrial.fits", "log_keptrial.txt", False)

@@ -102,55 +102,8 @@
 ame%0A
-from astropy.utils.misc import NumpyRNGContext%0A
 from
@@ -130,16 +130,16 @@
 eptrial%0A
+
 from ..k
@@ -319,43 +319,8 @@
 ():%0A
-    with NumpyRNGContext(123):%0A    
     
@@ -397,20 +397,16 @@
 X_ERR',%0A
-    
         
@@ -469,20 +469,16 @@
 e=True)%0A
-    
     f = 
@@ -506,20 +506,16 @@
 .fits%22)%0A
-    
     asse
@@ -557,20 +557,16 @@
 ) %3C 0.1%0A
-    
     dele

update test_keptrial.py