summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-10-03 15:15:38 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-10-03 15:15:38 (GMT)
commit32562d7da388819f46b91feeb74915bc0ad4686a (patch)
treeb5982603dd2c27f1a2978bbc18144456fceb4f31 /Lib
parentb48cb29ac4b9ac6b7e2a835c70c4fdd1b5333bcf (diff)
downloadcpython-32562d7da388819f46b91feeb74915bc0ad4686a.zip
cpython-32562d7da388819f46b91feeb74915bc0ad4686a.tar.gz
cpython-32562d7da388819f46b91feeb74915bc0ad4686a.tar.bz2
#12780: update inspect test skipIf for PEP 3147.
The test needs to be skipped if unicodedata is either part of the main binary (a repackaging of cpython on Windows?) or has python source (pypy?). PEP 3147 makes __file__ point to the .py source, so we need to change the extension check from looking for the old .pyc/.pyo to just looking for .py. Note that this skip should never trigger on CPython itself, so one could argue it should be dropped instead. But since it exists, why risk breaking someone else's python.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_inspect.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index da0572d..66d3fab 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -432,10 +432,11 @@ class TestBuggyCases(GetSourceBase):
def test_method_in_dynamic_class(self):
self.assertSourceEqual(mod2.method_in_dynamic_class, 95, 97)
- @unittest.skipIf(
- not hasattr(unicodedata, '__file__') or
- unicodedata.__file__[-4:] in (".pyc", ".pyo"),
- "unicodedata is not an external binary module")
+ # This should not skip for CPython, but might on a repackaged python where
+ # unicodedata is not an external module, or on pypy.
+ @unittest.skipIf(not hasattr(unicodedata, '__file__') or
+ unicodedata.__file__.endswith('.py'),
+ "unicodedata is not an external binary module")
def test_findsource_binary(self):
self.assertRaises(OSError, inspect.getsource, unicodedata)
self.assertRaises(OSError, inspect.findsource, unicodedata)