From 3d02248afe0c1fee2e29ab9828e63b1470363a61 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Thu, 30 Jun 2016 23:04:22 -0700 Subject: [PATCH] PyPy compatibility tests! (tested with v5.3.1 - Python 2.7 compatible - working) --- polyloader/_python2.py | 2 +- tests/test_import.py | 8 ++------ tests/test_paths.py | 15 +++++++++++++-- tox.ini | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/polyloader/_python2.py b/polyloader/_python2.py index 05bc5cc..72a8894 100644 --- a/polyloader/_python2.py +++ b/polyloader/_python2.py @@ -157,7 +157,7 @@ class PolyFinder(object): def _polyloader_pathhook(path): if not os.path.isdir(path): - raise ImportError('Only directories are supported', path=path) + raise ImportError('Only directories are supported: %s' % path) return PolyFinder(path) diff --git a/tests/test_import.py b/tests/test_import.py index 5d6c211..b8f23e9 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -71,13 +71,8 @@ class Test_Imports(object): print >> f, "a =", a print >> f, "b =", b - if os.path.exists(source): - print "%s EXISTS..." % source - try: - print "IMPORT..." mod = __import__(TESTFN) - print "END IMPORT..." except ImportError, err: print("import from %s (%s) failed: %s" % (ext, os.curdir, err)) assert(False) @@ -91,7 +86,8 @@ class Test_Imports(object): if not sys.dont_write_bytecode: imp.reload(mod) except ImportError, err: - self.fail("import from .pyc/.pyo failed: %s" % err) + print("import from .pyc/.pyo failed: %s" % err) + assert(False) finally: clean_tmpfiles(source) unload(TESTFN) diff --git a/tests/test_paths.py b/tests/test_paths.py index 6da4180..36e344d 100644 --- a/tests/test_paths.py +++ b/tests/test_paths.py @@ -38,6 +38,17 @@ def unload(name): except KeyError: pass +def rmtree(path): + def _rmtree_inner(path): + for name in os.listdir(path): + fullname = os.path.join(path, name) + if os.path.isdir(fullname): + _waitfor(_rmtree_inner, fullname, waitall=True) + os.rmdir(fullname) + else: + os.unlink(fullname) + _rmtree_inner(path) + os.rmdir(path) class Test_Paths: path = TESTFN @@ -53,9 +64,9 @@ class Test_Paths: # Regression test for http://bugs.python.org/issue1293. def test_trailing_slash(self): with open(os.path.join(self.path, 'test_trailing_slash.2'), 'w') as f: - f.write("testdata = 'test_trailing_slash'") + f.write("Test Trailing Slash\n") sys.path.append(self.path+'/') mod = __import__("test_trailing_slash") - self.assertEqual(mod.testdata, 'test_trailing_slash') + assert(mod.result == 'Success for 2: Test Trailing Slash') unload("test_trailing_slash") diff --git a/tox.ini b/tox.ini index 4df6d80..e4d8621 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py26, py27 +envlist = py26, py27, pypy ; , py33, py34, py35 [testenv]