GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-103186: Fix or catch 'extra' stderr output from unittests by TabLand · Pull Request #103196 · python/cpython

Conversation

@TabLand

@TabLand TabLand commented Apr 2, 2023 •
edited by terryjreedy
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.

  • Issue: Regression tests pass but return unnecessary output (errors and warnings) #103186

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zware reacted with hooray emoji
All reactions
  • 🎉 1 reaction
TabLand added 4 commits April 2, 2023 13:18
@TabLand
Suppress stderr for uuid3
0b03385
The exception raised is expected and is part of the unit test
@TabLand
Merge branch 'python:main' into fix-issue-103186
d6b0872
@TabLand
Suppress stderr with an additional assert, as elsewhere in test_warnings
b2d51e6
@TabLand
According to subprocess documentation, specifying pass_fds forces clo…
d697268
…se_fds to be True
@bedevere-bot bedevere-bot added the awaiting review label Apr 2, 2023
@bedevere-bot bedevere-bot mentioned this pull request Apr 2, 2023
Regression tests pass but return unnecessary output (errors and warnings) #103186
Closed
@bedevere-bot

This comment was marked as resolved.

Sign in to view
@ghost

ghost commented Apr 2, 2023 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood AlexWaygood added the skip news label Apr 2, 2023
@TabLand
Merge branch 'main' into fix-issue-103186
f9c2244
@TabLand

TabLand commented Apr 2, 2023

Copy link
Copy Markdown
Contributor Author

Please let me know if changes to individual files should be separated, would this separation have to be done both at the commit and branch level?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@terryjreedy

terryjreedy commented Apr 3, 2023

Copy link
Copy Markdown
Member

The azure pipeline failure page is https://dev.azure.com/Python/cpython/_build/results?buildId=123893&view=logs&j=d554cd63-f8f4-5b2d-871b-33e4ea76e915&t=5a14d0eb-dbd4-5b80-f5d0-7909f950a1cc.

In the first run, "3 tests failed: test_asyncgen test_logging test_subprocess". In the rerun, all 3 passed, but a normal sys.exit(0) failed with a PermissionError. We have seen this before, but I thought it was fixed. I am dubious that the patch would be responsible. I may ask about this tomorrow.

These three files together look fine together. I think that changes look good; will try to do some testing tomorrow.

TabLand and erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TabLand

TabLand commented Apr 3, 2023

Copy link
Copy Markdown
Contributor Author

Thanks Terry!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@arhadthedev
Merge branch 'main' into fix-issue-103186
1cde806
@arhadthedev arhadthedev added the tests Tests in the Lib/test dir label Apr 6, 2023
@TabLand
Merge branch 'main' into fix-issue-103186
edaf957
@TabLand

TabLand commented Jul 8, 2023

Copy link
Copy Markdown
Contributor Author

bump!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@terryjreedy terryjreedy changed the title gh-103186: Make test output cleaner gh-103186: Fix or catch 'extra' stderr output from unittests Jul 10, 2023
terryjreedy
terryjreedy approved these changes Jul 10, 2023
View reviewed changes

@terryjreedy terryjreedy left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I verified that these 3 tests run cleanly on Windows.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Jul 10, 2023
@terryjreedy terryjreedy added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jul 10, 2023
@terryjreedy
terryjreedy merged commit 9d58225 into python:main Jul 10, 2023
@miss-islington

miss-islington commented Jul 10, 2023

Copy link
Copy Markdown
Contributor

Thanks @TabLand for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting merge label Jul 10, 2023
@miss-islington

miss-islington commented Jul 10, 2023

Copy link
Copy Markdown
Contributor

Sorry, @TabLand and @terryjreedy, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 9d582250d8fde240b8e7299b74ba888c574f74a3 3.11

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 10, 2023
@TabLand @arhadthedev @miss-islington
pythongh-103186: Fix or catch 'extra' stderr output from unittests (p…
988c8f1
…ythonGH-103196)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

(cherry picked from commit 9d58225)

Co-authored-by: Ijtaba Hussain <[email protected]>
Co-authored-by: Oleg Iarygin <[email protected]>
@miss-islington miss-islington assigned terryjreedy Jul 10, 2023
@bedevere-bot

bedevere-bot commented Jul 10, 2023

Copy link
Copy Markdown

GH-106605 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jul 10, 2023
terryjreedy added a commit to terryjreedy/cpython that referenced this pull request Jul 10, 2023
@terryjreedy @arhadthedev
[3.11] pythongh-103186: Fix or catch 'extra' stderr output from unitt…
489d8e8
…ests (python#103196)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

Co-authored-by: Oleg Iarygin <[email protected]>
(cherry picked from commit 9d58225)
@bedevere-bot

bedevere-bot commented Jul 10, 2023

Copy link
Copy Markdown

GH-106606 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 10, 2023
terryjreedy pushed a commit that referenced this pull request Jul 10, 2023
@miss-islington @TabLand @arhadthedev
[3.12] gh-103186: Fix or catch 'extra' stderr output from unittests (G…
68ca190
…H-103196) (#106605)

gh-103186: Fix or catch 'extra' stderr output from unittests (GH-103196)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

(cherry picked from commit 9d58225)

Co-authored-by: Ijtaba Hussain <[email protected]>
Co-authored-by: Oleg Iarygin <[email protected]>
terryjreedy added a commit that referenced this pull request Jul 10, 2023
@terryjreedy @arhadthedev
[3.11] gh-103186: Fix or catch 'extra' stderr output from unittests (#…
563829d
…103196) (#106606)

Reduce test noise by fixing or catching and testing stderr messages from individual tests.

test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.

test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.

test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------

Co-authored-by: Oleg Iarygin <[email protected]>
(cherry picked from commit 9d58225)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@terryjreedy terryjreedy terryjreedy approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@terryjreedy terryjreedy

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@TabLand @bedevere-bot @terryjreedy @miss-islington @arhadthedev @AlexWaygood
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.