Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-112730: Make the test suite resilient to color-activation environment variables#117672

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pablogsal merged 8 commits intopython:mainfrompablogsal:no_colorize
Apr 24, 2024

Conversation

pablogsal
Copy link
Member

@pablogsalpablogsal commentedApr 9, 2024
edited by bedevere-appbot
Loading

@hugovkhugovk changed the titlegh-112730: Make the test suite relient to color-activation environment variablesgh-112730: Make the test suite resilient to color-activation environment variablesApr 9, 2024
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@gvanrossum
Copy link
Member

I am kind of sad that the solution is to add a special hack to suppress color to every test that would break. My ideal solution would be to suppress the color variables when-E is used, or for the traceback code to be able to detect whether-E is used.

@pablogsal
Copy link
MemberAuthor

pablogsal commentedApr 9, 2024
edited
Loading

I am kind of sad that the solution is to add a special hack to suppress color to every test that would break. My ideal solution would be to suppress the color variables when-E is used, or for the traceback code to be able to detect whether-E is used.

That only takes half of the tests because that fixes the cases where the traceback is taken from a subprocess. The other half which is when the traceback is taken from the process that runs test itself you need the decorator because the test suite cannot be executed itself always with -E.

To be honest I am happy to go this route (ignore on -E) but as@gpshead had some concerns with that I went with the most general solution first

@gvanrossum
Copy link
Member

Got it. I wonder if_can_colorize() is also a bit naive? Its default is to checking whether stderr is a tty, even when its caller is going to write to some other stream.

gpshead reacted with thumbs up emoji

@hugovk
Copy link
Member

That came up for termcolor and we replaced:

return (hasattr(sys.stdout,"isatty")andsys.stdout.isatty()andos.environ.get("TERM")!="dumb"    )

With:

# Then check system:ifos.environ.get("TERM")=="dumb":returnFalseifnothasattr(sys.stdout,"fileno"):returnFalsetry:returnos.isatty(sys.stdout.fileno())exceptio.UnsupportedOperation:returnsys.stdout.isatty()

https://github.com/termcolor/termcolor/pull/56/files

gpshead reacted with thumbs up emoji

Copy link
Member

@gpsheadgpshead left a comment

Choose a reason for hiding this comment

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

So long as the number of decorator applications isn't huge I think this works. We should pay attention to users during the alpha and beta cycle. I'm assuming they aren't likely to find issues with this in CI and they probably do not enable colors there. It feels more likely to happen to an end user developer working within their local dev environment (which I believe is how we found it amongst ourselves?)

Copy link
Member

Choose a reason for hiding this comment

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

There's enough decorators in this test file I suggest just disabling it via setUpModule / tearDownModule instead.

@gpshead
Copy link
Member

FWIW I do not mind if we just wind up disabling it entirely on-E, especially for the initial release of the feature. I agree that regardless of a PYTHON_ environment variable name prefix, it is a natural behavior change for people to look to -E and expect it to do.

gvanrossum reacted with thumbs up emoji

@pablogsal
Copy link
MemberAuthor

Ok, I will move to disable on-E then and remove as many decorators as possible.

pablogsaland others added3 commitsApril 10, 2024 11:19
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@hugovk
Copy link
Member

This test is failing:

FAIL:test_colorized_detection_checks_for_environment_variables (test.test_traceback.TestColorizedTraceback.test_colorized_detection_checks_for_environment_variables)----------------------------------------------------------------------Traceback (most recent call last):  File"D:\a\cpython\cpython\Lib\test\test_traceback.py", line4376, intest_colorized_detection_checks_for_environment_variablesself.assertEqual(traceback._can_colorize(),False)~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError:True != False

Does it also need@force_not_colorized?

@pablogsalpablogsalforce-pushed theno_colorize branch 2 times, most recently from1526a99 to4882250CompareApril 24, 2024 15:19
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@pablogsalpablogsal merged commit345e1e0 intopython:mainApr 24, 2024
31 checks passed
@pablogsalpablogsal deleted the no_colorize branchApril 24, 2024 20:25
@hugovkhugovk mentioned this pull requestApr 25, 2024
@kulikjak
Copy link
Contributor

kulikjak commentedApr 25, 2024
edited by hugovk
Loading

Hi. With this change, I am seeking several failures like the following one intest_traceback andtest_tracemalloc:

======================================================================FAIL:test_env_var_invalid (test.test_tracemalloc.TestCommandLine.test_env_var_invalid) (nframe=-1)----------------------------------------------------------------------Traceback (most recent call last):  File"/..../pythonmain/cpython-main/Lib/test/test_tracemalloc.py", line959, intest_env_var_invalidself.check_env_var_invalid(nframe)~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^  File"/..../pythonmain/cpython-main/Lib/test/test_tracemalloc.py", line953, incheck_env_var_invalidself.fail(f"unexpected output:{stderr!a}")~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError:unexpected output: b'ld.so.1: python: fatal: libpython3.13.so.1.0: open failed: No such file or directory\nld.so.1: python: fatal: relocation error: file /..../pythonmain/build/sparcv9/python: symbol Py_BytesMain: referenced symbol not found\n'

It seems that because the environment is now being cleared in those tests,LD_LIBRARY_PATH is no longer set in the subprocess, andlibpython3.13.so.1.0 thus not found.

I am seeing this on Oracle Solaris, though atm I don't think this is specific to us? Also, I am executing the test suite in a pretty standard way:

cd /..../pythonmain/build/sparcv9; EXTRATESTOPTS="-v test_traceback test_tracemalloc" /usr/gnu/bin/make test

@pablogsal
Copy link
MemberAuthor

I will look into this today!

kulikjak and nineteendo reacted with thumbs up emoji

@ericsnowcurrently
Copy link
Member

FWIW, I've seen failures in test_traceback/test_tracemalloc on a number of stable buildbots since this change.

pablogsal reacted with thumbs up emoji

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

@gpsheadgpsheadgpshead left review comments

@hugovkhugovkhugovk left review comments

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@terryjreedyterryjreedyAwaiting requested review from terryjreedyterryjreedy is a code owner

@iritkatrieliritkatrielAwaiting requested review from iritkatrieliritkatriel is a code owner

@markshannonmarkshannonAwaiting requested review from markshannon

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@ezio-melottiezio-melottiAwaiting requested review from ezio-melottiezio-melotti is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@pablogsal@gvanrossum@hugovk@gpshead@kulikjak@ericsnowcurrently

[8]ページ先頭

©2009-2025 Movatter.jp