Skip to content

Commit

Permalink
TST: Restore skip for warnings
Browse files Browse the repository at this point in the history
Skip releated warnings test on Python 2.7
  • Loading branch information
bashtage committed Aug 11, 2018
1 parent d98fc23 commit 39a6926
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions statsmodels/genmod/tests/test_glm_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ def setup_class(cls):
cls.res2 = mod2.fit()


@pytest.mark.skipif(not PY3, reason='pytest warning capture does is buggy on 2.x')
def test_warnings_raised():
weights = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3]
# faking aweights by using normalized freq_weights
Expand All @@ -775,28 +776,17 @@ def test_warnings_raised():

cov_kwds = {'groups': gid, 'use_correction': False}

# Workaround for buggy pytest repeated warnings capture in Python 2.7
# pytest/#2917
# Save the filters
filters = warnings.filters[:]
warnings.resetwarnings()
warnings.simplefilter('always', SpecificationWarning)

with pytest.warns(SpecificationWarning):
res1 = GLM(cpunish_data.endog, cpunish_data.exog,
family=sm.families.Poisson(), freq_weights=weights
).fit(cov_type='cluster', cov_kwds=cov_kwds)
res1.summary()

warnings.resetwarnings()
warnings.simplefilter('always', SpecificationWarning)
with pytest.warns(SpecificationWarning):
res1 = GLM(cpunish_data.endog, cpunish_data.exog,
family=sm.families.Poisson(), var_weights=weights
).fit(cov_type='cluster', cov_kwds=cov_kwds)
res1.summary()
# Restore the filters
warnings.filters.extend(filters)


weights = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3]
Expand Down

0 comments on commit 39a6926

Please sign in to comment.