-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
[WIP] STY: activate pytest.raises context manager code check #25750
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
Changes from all commits
1c4723f
f12eb4c
2cfb06d
472e375
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,8 +339,8 @@ def check_pow(self, lhs, arith1, rhs): | |
|
||
if (is_scalar(lhs) and is_scalar(rhs) and | ||
_is_py3_complex_incompat(result, expected)): | ||
pytest.raises(AssertionError, tm.assert_numpy_array_equal, | ||
result, expected) | ||
with pytest.raises(AssertionError): | ||
tm.assert_numpy_array_equal(result, expected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't convert this on first pass since test is skipped on windows. looking at it again, the assertion error check is used in lieu of a tm.assert_numpy_array_not_equal function so message check not appropriate. |
||
else: | ||
tm.assert_almost_equal(result, expected) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -416,9 +416,10 @@ def test_columns_with_dups(self): | |
[[1, 2, 1., 2., 3., 'foo', 'bar']], columns=list('ABCDEFG')) | ||
assert_frame_equal(df, expected) | ||
|
||
# TODO: fix this. does not raise. | ||
# this is an error because we cannot disambiguate the dup columns | ||
pytest.raises(Exception, lambda x: DataFrame( | ||
[[1, 2, 'foo', 'bar']], columns=['a', 'a', 'a', 'a'])) | ||
# with pytest.raises(Exception, match="<enter message here>"): | ||
# DataFrame([[1, 2, 'foo', 'bar']], columns=['a', 'a', 'a', 'a']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does not raise. added a TODO. not in this PR though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this not failing CI before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WillAyd . case of lambda x: with no x raises TypeError and so passed CI. |
||
|
||
# dups across blocks | ||
df_float = DataFrame(np.random.randn(10, 3), dtype='float64') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
from pandas import Int64Index, Interval, IntervalIndex | ||
import pandas.util.testing as tm | ||
|
||
# TODO: unskip these tests and enter error messages for pytest.raises | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this whole module is skipped. added a TODO. not in this PR though. |
||
pytestmark = pytest.mark.skip(reason="new indexing tests for issue 16316") | ||
|
||
|
||
|
@@ -49,7 +50,8 @@ def test_get_loc_scalar(self, closed, scalar): | |
if scalar in correct[closed].keys(): | ||
assert idx.get_loc(scalar) == correct[closed][scalar] | ||
else: | ||
pytest.raises(KeyError, idx.get_loc, scalar) | ||
with pytest.raises(KeyError, match="<enter message here>"): | ||
idx.get_loc(scalar) | ||
|
||
def test_slice_locs_with_interval(self): | ||
|
||
|
@@ -89,13 +91,19 @@ def test_slice_locs_with_interval(self): | |
# unsorted duplicates | ||
index = IntervalIndex.from_tuples([(0, 2), (2, 4), (0, 2)]) | ||
|
||
pytest.raises(KeyError, index.slice_locs( | ||
start=Interval(0, 2), end=Interval(2, 4))) | ||
pytest.raises(KeyError, index.slice_locs(start=Interval(0, 2))) | ||
with pytest.raises(KeyError, match="<enter message here>"): | ||
index.slice_locs(start=Interval(0, 2), end=Interval(2, 4)) | ||
|
||
with pytest.raises(KeyError, match="<enter message here>"): | ||
index.slice_locs(start=Interval(0, 2)) | ||
|
||
assert index.slice_locs(end=Interval(2, 4)) == (0, 2) | ||
pytest.raises(KeyError, index.slice_locs(end=Interval(0, 2))) | ||
pytest.raises(KeyError, index.slice_locs( | ||
start=Interval(2, 4), end=Interval(0, 2))) | ||
|
||
with pytest.raises(KeyError, match="<enter message here>"): | ||
index.slice_locs(end=Interval(0, 2)) | ||
|
||
with pytest.raises(KeyError, match="<enter message here>"): | ||
index.slice_locs(start=Interval(2, 4), end=Interval(0, 2)) | ||
|
||
# another unsorted duplicates | ||
index = IntervalIndex.from_tuples([(0, 2), (0, 2), (2, 4), (1, 3)]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,21 +134,23 @@ def test_partial_set( | |
|
||
def test_partial_ix_missing( | ||
self, multiindex_year_month_day_dataframe_random_data): | ||
pytest.skip("skipping for now") | ||
pytest.skip("skipping for now") # TODO: fix this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test is skipped. added a TODO. not in this PR though. |
||
|
||
ymd = multiindex_year_month_day_dataframe_random_data | ||
result = ymd.loc[2000, 0] | ||
expected = ymd.loc[2000]['A'] | ||
tm.assert_series_equal(result, expected) | ||
|
||
# need to put in some work here | ||
# TODO: need to put in some work here | ||
|
||
# self.ymd.loc[2000, 0] = 0 | ||
# assert (self.ymd.loc[2000]['A'] == 0).all() | ||
|
||
# Pretty sure the second (and maybe even the first) is already wrong. | ||
pytest.raises(Exception, ymd.loc.__getitem__, (2000, 6)) | ||
pytest.raises(Exception, ymd.loc.__getitem__, (2000, 6), 0) | ||
with pytest.raises(Exception, match="<enter message here>"): | ||
ymd.loc.__getitem__((2000, 6)) | ||
with pytest.raises(Exception, match="<enter message here>"): | ||
ymd.loc.__getitem__((2000, 6), 0) | ||
|
||
# --------------------------------------------------------------------- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1118,8 +1118,10 @@ def test_constructor_dtype_timedelta64(self): | |
assert td.dtype == 'timedelta64[ns]' | ||
|
||
# these are frequency conversion astypes | ||
# TODO: fix this. does not raise. | ||
# for t in ['s', 'D', 'us', 'ms']: | ||
# pytest.raises(TypeError, td.astype, 'm8[%s]' % t) | ||
# with pytest.raises(TypeError, match="<enter message here>"): | ||
# td.astype('m8[%s]' % t) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does not raise. added a TODO. not in this PR though. |
||
|
||
# valid astype | ||
td.astype('int64') | ||
|
Uh oh!
There was an error while loading. Please reload this page.