From 39a6926f0b9e673b96413b633e76daab034efc69 Mon Sep 17 00:00:00 2001 From: Kevin Sheppard Date: Sat, 11 Aug 2018 23:15:23 +0100 Subject: [PATCH] TST: Restore skip for warnings Skip releated warnings test on Python 2.7 --- statsmodels/genmod/tests/test_glm_weights.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/statsmodels/genmod/tests/test_glm_weights.py b/statsmodels/genmod/tests/test_glm_weights.py index 74fc247e383..f584dc27209 100644 --- a/statsmodels/genmod/tests/test_glm_weights.py +++ b/statsmodels/genmod/tests/test_glm_weights.py @@ -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 @@ -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]