[2.7] bpo-30366: Backport tests for test.support.#1582
[2.7] bpo-30366: Backport tests for test.support.#1582serhiy-storchaka merged 3 commits intopython:2.7from
Conversation
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.
vstinner
left a comment
There was a problem hiding this comment.
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.
Lib/test/support/__init__.py
Outdated
| except AttributeError: | ||
| raise unittest.SkipTest("module %s has no attribute %s" % ( | ||
| obj.__name__, name)) | ||
| if isinstance(obj, type(sys)): |
There was a problem hiding this comment.
I guess that the code is the same in master. I am surprised that types.ModuleType is not used here.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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.