Skip to content

Commit

Permalink
Fixes #1. Have tests inspect an exception's e.value instead of just t…
Browse files Browse the repository at this point in the history
…he exception. pytest 5.0.0 no longer displays the custom text with str(e)
  • Loading branch information
Terrence Wong committed Jun 29, 2019
1 parent 6a99988 commit 5d469df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions stingray/pulse/tests/test_search.py
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
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)

0 comments on commit 5d469df

Please sign in to comment.