Skip to content

STY: use pytest.raises context manager (generic) #25603

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

Merged
merged 1 commit into from
Mar 9, 2019

Conversation

simonjayhawkins
Copy link
Member

xref #24332

@codecov
Copy link

codecov bot commented Mar 8, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25603      +/-   ##
==========================================
+ Coverage   91.26%   91.26%   +<.01%     
==========================================
  Files         173      173              
  Lines       52968    52968              
==========================================
+ Hits        48339    48340       +1     
+ Misses       4629     4628       -1
Flag Coverage Δ
#multiple 89.83% <ø> (ø) ⬆️
#single 41.71% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/util/testing.py 87.66% <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 5c159d2...4b3789e. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Mar 8, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25603      +/-   ##
==========================================
+ Coverage   91.26%   91.26%   +<.01%     
==========================================
  Files         173      173              
  Lines       52968    52968              
==========================================
+ Hits        48339    48340       +1     
+ Misses       4629     4628       -1
Flag Coverage Δ
#multiple 89.83% <ø> (ø) ⬆️
#single 41.71% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/util/testing.py 87.66% <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 5c159d2...4b3789e. Read the comment docs.

Copy link
Member

@alimcmaster1 alimcmaster1 left a comment

Choose a reason for hiding this comment

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

Generally LGTM - few minor comments


# multiple bool are still an error
msg = "The truth value of a Series is ambiguous"
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: Do we need to define this string 3 times in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

fine for now...

this is surely an indication of tests that could be refactored to use more pytest idiom... but that'll be for a follow-up.

also the messages serve as additional documentation for the tests


# invalid behaviors

obj1 = self._construct(shape=4, value=1)
obj2 = self._construct(shape=4, value=1)

def f():
with pytest.raises(ValueError, match=msg):
Copy link
Member

Choose a reason for hiding this comment

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

This should be fine to remove as this exact behaviour is tested on line 151 right?

Copy link
Member Author

Choose a reason for hiding this comment

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

@alimcmaster1 : I'm not sure that this should be removed. I think it was added for a reason. If it could be removed then the remaining part of the test would probably be redundant as well.

probably related to the fact that bool(obj == 0) raises whereas obj == 0 does not.

@jreback jreback added Testing pandas testing functions or related to the test suite Code Style Code style, linting, code_checks labels Mar 9, 2019
@jreback jreback added this to the 0.25.0 milestone Mar 9, 2019
@jreback jreback merged commit 69905c5 into pandas-dev:master Mar 9, 2019
@jreback
Copy link
Contributor

jreback commented Mar 9, 2019

thanks @simonjayhawkins

@simonjayhawkins simonjayhawkins deleted the cm-generic branch March 10, 2019 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks 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