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

REF/TST: Add more pytest idiom to indexing/multiindex/test_getitem.py #24452

Merged
merged 9 commits into from
Dec 28, 2018

Conversation

simonjayhawkins
Copy link
Member

@simonjayhawkins simonjayhawkins commented Dec 27, 2018

in this pass:

@codecov
Copy link

codecov bot commented Dec 27, 2018

Codecov Report

Merging #24452 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24452      +/-   ##
==========================================
+ Coverage    92.3%   92.31%   +<.01%     
==========================================
  Files         163      163              
  Lines       51987    51987              
==========================================
+ Hits        47989    47990       +1     
+ Misses       3998     3997       -1
Flag Coverage Δ
#multiple 90.72% <ø> (ø) ⬆️
#single 42.99% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/util/testing.py 87.84% <0%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08c920e...062e48f. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 27, 2018

Codecov Report

Merging #24452 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24452      +/-   ##
==========================================
- Coverage    92.3%    92.3%   -0.01%     
==========================================
  Files         163      163              
  Lines       51987    51969      -18     
==========================================
- Hits        47989    47968      -21     
- Misses       3998     4001       +3
Flag Coverage Δ
#multiple 90.7% <ø> (-0.02%) ⬇️
#single 43.01% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/period.py 92.75% <0%> (-0.33%) ⬇️
pandas/core/indexes/timedeltas.py 90.11% <0%> (-0.31%) ⬇️
pandas/tseries/offsets.py 96.69% <0%> (-0.26%) ⬇️
pandas/core/arrays/datetimelike.py 95.93% <0%> (-0.22%) ⬇️
pandas/core/indexes/datetimes.py 96.31% <0%> (-0.02%) ⬇️
pandas/util/testing.py 87.84% <0%> (+0.09%) ⬆️
pandas/core/indexes/datetimelike.py 97.7% <0%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08c920e...4e9a70f. Read the comment docs.

@jreback jreback added Testing pandas testing functions or related to the test suite Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex labels Dec 27, 2018


def test_getitem_int(multiindex_dataframe_random_data):
@pytest.fixture
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally put the fixtures at the top

frame = multiindex_dataframe_random_data.T
expected = frame
df = frame.copy()

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't do things like this; use the context manager like above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've changed as requested. though not convinced this is the right thing to do in situations like this. the previous test tested that the chained assignment raised the correct exception and this test is to check that the dataframe values are unchanged. having a context manager in the test adds unnecessary/unseen setup and teardown code that could potentially interfere with the tested functionality.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this must have been changed a while back, the context manager is the correct idiom

@jreback jreback added this to the 0.24.0 milestone Dec 28, 2018
@jreback jreback merged commit b37d95d into pandas-dev:master Dec 28, 2018
@jreback
Copy link
Contributor

jreback commented Dec 28, 2018

thanks @simonjayhawkins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants