Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1. Have tests inspect an exception's e.value instead of just t… #417

Closed
wants to merge 11 commits into from
34 changes: 0 additions & 34 deletions stingray/conftest.py

This file was deleted.

6 changes: 3 additions & 3 deletions stingray/pulse/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_phaseogram_bad_weights(self):
phaseogr, phases, times, additional_info = \
phaseogram(self.event_times, self.pulse_frequency,
weights=[0, 2])
assert 'must match' in str(excinfo)
assert 'must match' in str(excinfo.value)

def test_phaseogram_weights(self):
phaseogr, phases, times, additional_info = \
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_epoch_folding_search_expocorr_fails(self):
with pytest.raises(ValueError) as excinfo:
freq, stat = epoch_folding_search(self.event_times, frequencies,
nbin=23, expocorr=True)
assert 'To calculate exposure correction' in str(excinfo)
assert 'To calculate exposure correction' in str(excinfo.value)

def test_epoch_folding_search_expocorr(self):
"""Test pulse phase calculation, frequency only."""
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_z_n_search_expocorr_fails(self):
with pytest.raises(ValueError) as excinfo:
freq, stat = z_n_search(self.event_times, frequencies, nharm=1,
nbin=35, expocorr=True)
assert 'To calculate exposure correction' in str(excinfo)
assert 'To calculate exposure correction' in str(excinfo.value)

def test_z_n_search_weights(self):
"""Test pulse phase calculation, frequency only."""
Expand Down
6 changes: 3 additions & 3 deletions stingray/tests/test_gti.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def test_gti_mask_fails_empty_time(self):
gti = np.array([[0, 2.1], [3.9, 5]])
with pytest.raises(ValueError) as excinfo:
create_gti_mask(arr, gti, return_new_gtis=True)
assert 'empty time array' in str(excinfo)
assert 'empty time array' in str(excinfo.value)

def test_gti_mask_fails_empty_gti(self):
arr = np.array([0, 1, 2, 3, 4, 5, 6])
gti = np.array([])
with pytest.raises(ValueError) as excinfo:
create_gti_mask(arr, gti, return_new_gtis=True)
assert 'empty GTI array' in str(excinfo)
assert 'empty GTI array' in str(excinfo.value)

def test_gti_mask_complete(self):
arr = np.array([0, 1, 2, 3, 4, 5, 6])
Expand Down Expand Up @@ -241,5 +241,5 @@ def test_check_gtis_values(self):
def test_check_gti_fails_empty(self):
with pytest.raises(ValueError) as excinfo:
check_gtis([])
assert 'Empty' in str(excinfo)
assert 'Empty' in str(excinfo.value)