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

Bugfix/capsys with cli logging (again) #3832

Merged
merged 8 commits into from
Aug 21, 2018

Conversation

Sup3rGeo
Copy link
Member

Solves more problems found related to #3819, improving previous PR #3822 also by refactoring a bit the capture module, mostly by separating the snapping of the global capture from its suspension.

  • Create a new changelog file in the changelog folder, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • Target the master branch for bug fixes, documentation updates and trivial changes.
  • Target the features branch for new features and removals/deprecations.
  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.

Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:

  • Add yourself to AUTHORS in alphabetical order;

@coveralls
Copy link

coveralls commented Aug 19, 2018

Coverage Status

Coverage increased (+0.07%) to 92.613% when pulling 70ebab3 on Sup3rGeo:bugfix/capsys-with-cli-logging into 28aff05 on pytest-dev:master.

@nicoddemus
Copy link
Member

nicoddemus commented Aug 19, 2018

This is great @Sup3rGeo, thanks a lot.

I see the main problem is that currently we drop the captured output between live log calls because we suspend the capture manager when emitting log records, and this PR fixes that.

Also great work on the refactoring, it reduces code and improves readability! 👍

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Great work @Sup3rGeo!

Besides two small comments, please also add a CHANGELOG entry. 👍

Just realized we already have a the CHANGELOG entry ready for #3819 😁

if outcome.excinfo is not None:
out, err = capman.snap_global_capture()
Copy link
Member

Choose a reason for hiding this comment

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

Since we are refactoring things, how do you feel about renaming this to read_global_capture?

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 was trying to use the same naming convention, as capture objects implement snap.

Should we then rename everything from snap to read? It seems a bit awkward to have read in global as all it does is to snap internally.

But to be honest I don't mind having either so I leave this decision for you :)

Copy link
Member

Choose a reason for hiding this comment

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

It is just that snap_global_capture does self._global_capturing.readouterr(), so I think renaming it here makes sense. Snap is then used just for the "Capture" classes. 😁

Copy link
Member Author

@Sup3rGeo Sup3rGeo Aug 20, 2018

Choose a reason for hiding this comment

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

Makes sense, will do it!

@@ -1387,27 +1391,53 @@ def test_pickling_and_unpickling_encoded_file():
pickle.loads(ef_as_str)


def test_capsys_with_cli_logging(testdir):
def test_capture_with_live_logging(testdir):
Copy link
Member

Choose a reason for hiding this comment

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

Please parametrize this test so it also tests with the capfd fixture. 👍

@Sup3rGeo
Copy link
Member Author

It seems like there is still a change to be addressed but I don't know how to do it

@nicoddemus
Copy link
Member

Thanks @Sup3rGeo, top notch work!

It seems like there is still a change to be addressed but I don't know how to do it

You mean the merge was blocked? That was because we configure the repository to block merges until no reviewers left the PR in the "requested changes" status. 😉

If nobody else comments until then, I will merge this later. 👍

@nicoddemus nicoddemus merged commit f1079a8 into pytest-dev:master Aug 21, 2018
@nicoddemus
Copy link
Member

Thanks again @Sup3rGeo!

@Sup3rGeo Sup3rGeo deleted the bugfix/capsys-with-cli-logging branch August 22, 2018 07:14
@asottile
Copy link
Member

Not sure how important this is, but this appears to have broken tox's test suite (between 3,7,2 and 3.7.3). To be fair though, tox was using capfd._start() directly which is probably a no-no.

tox-dev/tox@6c7ea27 I believe fixes what I'm seeing

@nicoddemus
Copy link
Member

thanks for the heads up @asottile, but I think it is fair game to change non-public API during bugfix releases. 👍

@asottile
Copy link
Member

Totally agree -- that's why I didn't make an issue 😆

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.

5 participants