Skip to content

Fix unwrapping stdout/stderr#117

Merged
wolph merged 1 commit into
wolph:developfrom
matthewwardrop:patch-1
May 30, 2017
Merged

Fix unwrapping stdout/stderr#117
wolph merged 1 commit into
wolph:developfrom
matthewwardrop:patch-1

Conversation

@matthewwardrop

@matthewwardrop matthewwardrop commented May 26, 2017

Copy link
Copy Markdown
Contributor

Hi @wolph,

Looks like you've got a couple of off-by-one errors here, which leads to the stdout/stderr not being restored appropriately. Causing some bugs downstream :).

@wolph

wolph commented May 26, 2017

Copy link
Copy Markdown
Owner

You're right, that doesn't work correctly. Although the fix is actually still a bit "wrong" as it keeps the counter at 1 once it's been incremented. Shouldn't really be a problem, but it's not as neat :P

I guess when resetting the stream it should just set the counter to 0 in all cases.

@matthewwardrop

matthewwardrop commented May 26, 2017

Copy link
Copy Markdown
Contributor Author

@wolph That was my fault... fixed. [It didn't always reset, since class is instantiated at import time.]

@matthewwardrop matthewwardrop force-pushed the patch-1 branch 3 times, most recently from 18d77e5 to a2934c2 Compare May 26, 2017 23:09
@matthewwardrop

Copy link
Copy Markdown
Contributor Author

Not sure what's triggering coverage that's different than master. Perhaps builds are broken there too?

When are you likely to be able to ship a new release with this patch?

@wolph

wolph commented May 26, 2017

Copy link
Copy Markdown
Owner

My weekend is a bit busy but I might have time on sunday, monday at the latest :)

As for the tests, I'm guessing the tests are simply broken. They worked for the old (wrong) code so with the new code they need to be changed as well: https://github.com/WoLpH/python-progressbar/blob/6ca8abf16f8b7f2ca9d958ea19a7fe8887d9d403/tests/test_stream.py
I can take a look when I merge if you'd prefer, shouldn't be too hard to fix them

@matthewwardrop

Copy link
Copy Markdown
Contributor Author

@wolph It's actually not the tests that are failing... but coverage. But since the patch only changes code within the methods, I'm not sure what's going on there.

Monday sounds great. Thanks for being so responsive!

@wolph

wolph commented May 26, 2017

Copy link
Copy Markdown
Owner

I understand, but due to the changed behaviour the else of that if statement is never reached which is why coverage is saying it isn't covered.

@matthewwardrop

Copy link
Copy Markdown
Contributor Author

I just realised as much (hitherto not used coverage). Will fix that too.

@wolph

wolph commented May 26, 2017

Copy link
Copy Markdown
Owner

Testing locally is much easier than using travis :)

pip install -r tests/requirements.txt
py.test

After that you should have a htmlcov directory containing the coverage. Simply open the index.html in your browser and you'll see which part is covered and which isn't.

@matthewwardrop

matthewwardrop commented May 26, 2017

Copy link
Copy Markdown
Contributor Author

Yep... figured it out :). Just adding a test now. Thanks!

Hi @wolph,

Looks like you've got a couple of off by one errors here, which leads to the stdout/stderr not being restored appropriately.
@matthewwardrop

Copy link
Copy Markdown
Contributor Author

I added a fairly esoteric test to test_stream.py, which tests that progress bars work on non-standard file-type outputs (i.e. StringIO vs sys.stdout/sys.stderr), which rounds coverage back out to 100%. Feel free to modify the test if needed.

@wolph wolph merged commit af1146b into wolph:develop May 30, 2017
wolph added a commit that referenced this pull request May 30, 2017
Fixed several bugs thanks to @matthewwardrop and refactored requirements

 - #119 Use get_ipython imported from IPython rather than global namespace
 - #118 Make printing a newline on finish optional
 - #117 Fix unwrapping stdout/stderr
 - Refactored `requirements.txt` files to use `setup.py`
@wolph

wolph commented May 30, 2017

Copy link
Copy Markdown
Owner

@matthewwardrop the new release is online and it seems to do the trick :)

Thanks for the help!

@matthewwardrop

Copy link
Copy Markdown
Contributor Author

Thanks @wolph !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants