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: Add test decorators for redirecting stdout and stderr #15952

Merged
merged 1 commit into from
Apr 8, 2017

Conversation

gfyoung
Copy link
Member

@gfyoung gfyoung commented Apr 8, 2017

Add testing decorators for redirecting stdout and stderr.

xref #15925 (comment)

@gfyoung gfyoung changed the title TST: Add test fixtures for redirecting stdout and stderr TST: Add test decorators for redirecting stdout and stderr Apr 8, 2017
@codecov
Copy link

codecov bot commented Apr 8, 2017

Codecov Report

Merging #15952 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15952      +/-   ##
==========================================
+ Coverage   90.99%      91%   +0.01%     
==========================================
  Files         145      145              
  Lines       49570    49576       +6     
==========================================
+ Hits        45106    45118      +12     
+ Misses       4464     4458       -6
Flag Coverage Δ
#multiple 88.77% <100%> (+0.01%) ⬆️
#single 40.57% <73.33%> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/util/decorators.py 65.3% <100%> (+3.04%) ⬆️
pandas/util/testing.py 81.13% <100%> (+0.24%) ⬆️

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 88f5851...9edafd9. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 8, 2017

Codecov Report

Merging #15952 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15952      +/-   ##
==========================================
+ Coverage   90.99%      91%   +0.01%     
==========================================
  Files         145      145              
  Lines       49570    49576       +6     
==========================================
+ Hits        45106    45118      +12     
+ Misses       4464     4458       -6
Flag Coverage Δ
#multiple 88.77% <100%> (+0.01%) ⬆️
#single 40.57% <73.33%> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/util/decorators.py 65.3% <100%> (+3.04%) ⬆️
pandas/util/testing.py 81.13% <100%> (+0.24%) ⬆️

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 0aef74f...82e11c1. Read the comment docs.

@jreback jreback added the Testing pandas testing functions or related to the test suite label Apr 8, 2017
@jreback jreback added this to the 0.20.0 milestone Apr 8, 2017

# Engines are verbose in different ways.
if self.engine == 'c':
self.assertIn('Tokenization took:', output)
Copy link
Contributor

Choose a reason for hiding this comment

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

while you are at it, can you use pytest idioms here, e.g. self.assertIn -> assert output in ......

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure thing. Done.

self.assertIn('Parser memory cleanup took:', output)
else: # Python engine
exp = 'Filled 1 NA values in column a\n'
self.assertEqual(output, exp)
Copy link
Contributor

Choose a reason for hiding this comment

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

assert output == exp

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, done.

con=self.conn)
finally:
sys.stdout = sys.__stdout__

Copy link
Contributor

Choose a reason for hiding this comment

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

use pytest.raises

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, done.

"""
Capture stdout in a buffer so that it can be checked
(or suppressed) during testing.
"""
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 say this is a decorator, and show how to use it. (same as on capture_stderr).

Copy link
Contributor

Choose a reason for hiding this comment

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

also move these near the other routine which maniuplates stdout (about encoding IIRC).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, done.

@gfyoung gfyoung force-pushed the stderr-test-fixture branch 2 times, most recently from f060903 to c4b934f Compare April 8, 2017 21:22
@jreback jreback merged commit 4e38396 into pandas-dev:master Apr 8, 2017
@jreback
Copy link
Contributor

jreback commented Apr 8, 2017

thanks @gfyoung !

@gfyoung gfyoung deleted the stderr-test-fixture branch April 8, 2017 22:01
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.

2 participants