Skip to content

[2.7] bpo-30366: Backport tests for test.support. #1582

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

Merged
merged 3 commits into from
May 15, 2017

Conversation

serhiy-storchaka
Copy link
Member

Also backport new functions temp_dir() and python_is_optimized().
temp_cwd() now accepts None as a name (means using tempfile.mkdtemp).
check_syntax_error() now accepts arguments lineno and offset.

Also backport new functions temp_dir() and python_is_optimized().
temp_cwd() now accepts None as a name (means using tempfile.mkdtemp).
check_syntax_error() now accepts arguments lineno and offset.
@serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement tests Tests in the Lib/test dir labels May 14, 2017
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

I didn't compare test_test_support with master. I guess that it's the same code or almost the same. Backported enhancements are fine.

LGTM.

@@ -155,8 +155,12 @@ def get_attribute(obj, name):
try:
attribute = getattr(obj, name)
except AttributeError:
raise unittest.SkipTest("module %s has no attribute %s" % (
obj.__name__, name))
if isinstance(obj, type(sys)):
Copy link
Member

Choose a reason for hiding this comment

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

I guess that the code is the same in master. I am surprised that types.ModuleType is not used here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is a hybrid between former 2.7 code and master code. In 2.7 it can be used only for modules, and reports module name on error. In master it can be used for arbitrary objects and reports object's repr on error (this looks worser for modules). I'm going to port this specialization to master.

types.ModuleType is not used because types is not imported in test.support and I don't want to add imports without need.

Copy link
Member

Choose a reason for hiding this comment

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

types is already imported by test.support through functools ;-) Again, it was just a comment, it's unrelated to the backport itself.

haypo@selma$ ./python -i -S
Python 3.7.0a0 (heads/shutdown_10022:1315e80, May 10 2017, 18:49:18) 
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
>>> import test
>>> import test.support
>>> import sys
>>> 'types' in sys.modules
True

@serhiy-storchaka serhiy-storchaka merged commit eb66897 into python:2.7 May 15, 2017
@serhiy-storchaka serhiy-storchaka deleted the test-test_support branch May 15, 2017 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants