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

TST: return pytest MarkDecorator from td.skip_if_no #26735

Merged
merged 4 commits into from
Jun 8, 2019

Conversation

simonjayhawkins
Copy link
Member

skip_if_no returns a decorator that applies a pytest mark.

pytest marks are decorators and can be applied directly to test functions.

This PR changes skip_if_no to return just the pytest mark.

skip_if_no can then be used in (pytest.param(... , marks=) situations. eg. pandas/tests/io/test_html.py

could also be used in pandas/tests/io/test_excel.py but not done here to avoid overlapping PRs.

safe_import could potentially be renamed _safe_import since would not be needed directly in tests.

cc @WillAyd

@simonjayhawkins simonjayhawkins added the Testing pandas testing functions or related to the test suite label Jun 8, 2019
@@ -99,36 +99,40 @@ def _skip_if_no_scipy():

def skip_if_no(package, min_version=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add annotations (return value in particular)

Copy link
Member Author

Choose a reason for hiding this comment

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

can you add annotations (return value in particular)

done

@codecov
Copy link

codecov bot commented Jun 8, 2019

Codecov Report

Merging #26735 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26735      +/-   ##
==========================================
- Coverage   91.78%   91.77%   -0.01%     
==========================================
  Files         174      174              
  Lines       50703    50701       -2     
==========================================
- Hits        46538    46532       -6     
- Misses       4165     4169       +4
Flag Coverage Δ
#multiple 90.37% <100%> (-0.01%) ⬇️
#single 41.8% <100%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/util/_test_decorators.py 92.98% <100%> (-0.24%) ⬇️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️

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 cf25c5c...8fe9f69. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 8, 2019

Codecov Report

Merging #26735 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26735      +/-   ##
==========================================
- Coverage   91.78%   91.77%   -0.01%     
==========================================
  Files         174      174              
  Lines       50703    50703              
==========================================
- Hits        46538    46534       -4     
- Misses       4165     4169       +4
Flag Coverage Δ
#multiple 90.37% <100%> (ø) ⬆️
#single 41.81% <100%> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/util/_test_decorators.py 93.22% <100%> (ø) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️

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 cf25c5c...c982e19. Read the comment docs.

@@ -97,38 +101,42 @@ def _skip_if_no_scipy():
safe_import('scipy.signal'))


Copy link
Contributor

Choose a reason for hiding this comment

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

why wouldn’t you make this MarkDecorator)

@WillAyd WillAyd added this to the 0.25.0 milestone Jun 8, 2019
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Nice change with much cleaner syntax going forward. Thanks @simonjayhawkins

not td.safe_import('lxml'), reason='No bs4')),
pytest.param('lxml', marks=pytest.mark.skipif(
not td.safe_import('lxml'), reason='No lxml'))], scope="class")
pytest.param('bs4', marks=td.skip_if_no('lxml')),
Copy link
Member

Choose a reason for hiding this comment

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

There are some of these in test_excel as well. Not sure if you meant to do all in this PR or not but if so worth a double check of other modules

Copy link
Member Author

Choose a reason for hiding this comment

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

left them intentionally to avoid conflicts with your PRs.

have checked other modules, no other use of safe_import except one case of a test decorator where I think skip_if_no could be used directly. (change that in this PR?)

@pytest.mark.skipif(td.safe_import('gcsfs'),
reason='Only check when gcsfs not installed')
def test_gcs_not_present_exception():

and test_safe_import.

@jreback jreback merged commit 5dcbc64 into pandas-dev:master Jun 8, 2019
@jreback
Copy link
Contributor

jreback commented Jun 8, 2019

thanks, possibly worthile to make an issue to identify places where we can fix this in the code (or just do it if not that hard)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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