[Jython-checkins] jython (merge default -> default): Merge misc fixes to trunk

jeff.allen jython-checkins at python.org
Mon Apr 20 00:50:16 CEST 2015


https://hg.python.org/jython/rev/5e12eb29a6bb
changeset:   7686:5e12eb29a6bb
parent:      7680:fbcbd5f9462b
parent:      7685:0689142744de
user:        Jeff Allen <ja.py at farowl.co.uk>
date:        Sun Apr 19 23:49:41 2015 +0100
summary:
  Merge misc fixes to trunk

files:
  Lib/test/regrtest.py                                           |  56 +++++++--
  Lib/test/test_java_integration.py                              |  11 +-
  Lib/test/test_zipimport_support.py                             |  29 +++-
  NEWS                                                           |   2 +
  build.xml                                                      |   6 +-
  src/org/python/core/packagecache/CachedJarsPackageManager.java |   4 +-
  6 files changed, 73 insertions(+), 35 deletions(-)


diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -376,16 +376,31 @@
         import trace
         tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
                              trace=False, count=True)
+
     test_times = []
     test_support.verbose = verbose      # Tell tests to be moderately quiet
     test_support.use_resources = use_resources
     test_support.junit_xml_dir = junit_xml
     save_modules = sys.modules.keys()
+
     skips = _ExpectedSkips()
     failures = _ExpectedFailures()
+
+    if expected:
+        # Suppress expected failure from the list of tests.
+        for t in failures.getexpected():
+            if t in tests:
+                tests.remove(t)
+        # Suppress expected skips from the list of tests.
+        for t in skips.getexpected():
+            if t in tests:
+                tests.remove(t)
+
+    # Prevent reporting unexpected success in things we failed to try
+    failures.keep_only(tests)
+    skips.keep_only(tests)
+
     for test in tests:
-        if expected and (test in skips or test in failures):
-            continue
         if not quiet:
             print test
             sys.stdout.flush()
@@ -517,7 +532,7 @@
 
 def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
     """Return a list of all applicable test modules."""
-    if not testdir: testdir = findtestdir()
+    testdir = findtestdir()
     names = os.listdir(testdir)
     tests = []
     for name in names:
@@ -792,13 +807,8 @@
     # Collect cyclic trash.
     gc.collect()
 
-def findtestdir():
-    if __name__ == '__main__':
-        file = sys.argv[0]
-    else:
-        file = __file__
-    testdir = os.path.dirname(file) or os.curdir
-    return testdir
+def findtestdir(path=None):
+    return path or os.path.dirname(__file__) or os.curdir
 
 def removepy(name):
     if name.endswith(os.extsep + "py"):
@@ -1260,8 +1270,8 @@
         test_locale
 
         # Should fix these tests so they are not hardcoded for CPython pyc files
-        # test_compileall
-        # test_pydoc
+        test_compileall
+        test_pydoc
 
         # Requires Python bytecode compilation support
         test_longexp
@@ -1343,7 +1353,7 @@
         self.valid = False
         if _platform in _expectations:
             s = _expectations[_platform]
-            self.expected = set(s.split())
+            self.expected = set(self.split_commented(s))
 
             # expected to be skipped on every platform, even Linux
             self.expected.add('test_linuxaudiodev')
@@ -1374,7 +1384,6 @@
             elif len(u'\0'.encode('unicode-internal')) == 4:
                 self.expected.add("test_macostools")
 
-
             if sys.platform != "win32":
                 # test_sqlite is only reliable on Windows where the library
                 # is distributed with Python
@@ -1423,12 +1432,29 @@
     def __contains__(self, key):
         return key in self.expected
 
+    def remove(self, item):
+        self.expected.remove(item)
+
+    def keep_only(self, items):
+        "Remove items not in the supplied iterable"
+        self.expected &= set(items)
+
+    @staticmethod
+    def split_commented(modlist):
+        """Split list of words (values from _expectations or _failures)
+           handling #-comments.
+        """
+        for line in modlist.splitlines():
+            trunc_line = line.split('#', 1)[0]
+            for word in trunc_line.split():
+                yield word
+
 class _ExpectedFailures(_ExpectedSkips):
     def __init__(self):
         self.valid = False
         if _platform in _failures:
             s = _failures[_platform]
-            self.expected = set(s.split())
+            self.expected = set(self.split_commented(s))
             self.valid = True
 
 def savememo(memo,good,bad,skipped):
diff --git a/Lib/test/test_java_integration.py b/Lib/test/test_java_integration.py
--- a/Lib/test/test_java_integration.py
+++ b/Lib/test/test_java_integration.py
@@ -748,7 +748,7 @@
             classpath = os.pathsep.join(jars)
             compile_java_source(
                 ["-classpath", classpath, "-d", tempdir],
-                "BarkTheDog", source)           
+                "BarkTheDog", source)
 
             # Then in a completely different JVM running our
             # BarkTheDog code, verify we get an appropriate bark
@@ -763,11 +763,8 @@
             self.assertRegexpMatches(
                 subprocess.check_output(cmd, env=env, universal_newlines=True,
                                         stderr=subprocess.STDOUT),
-                os.path.join(
-                    r"^\*sys-package-mgr\*: processing new jar, '.+?",
-                    r"proxies.jar'\n"
-                    "Class defined on CLASSPATH <type 'org.python.test.bark.Dog'>\n"
-                    "Rover barks 42 times\n$".format(tempdir)))
+                r"^Class defined on CLASSPATH <type 'org.python.test.bark.Dog'>\n"
+                                        "Rover barks 42 times$")
         finally:
             pass
             # print "Will not remove", tempdir
@@ -775,7 +772,7 @@
 
 
 class CopyTest(unittest.TestCase):
-    
+
     def test_copy(self):
         fruits = ArrayList(["apple", "banana"])
         fruits_copy = copy.copy(fruits)
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -31,7 +31,8 @@
 #  test_cmd_line_script (covers the zipimport support in runpy)
 
 # Retrieve some helpers from other test cases
-from test import test_doctest, sample_doctest
+from test import (test_doctest, sample_doctest, sample_doctest_no_doctests,
+                  sample_doctest_no_docstrings)
 from test.test_importhooks import ImportHooksBaseTestCase
 
 if is_jython and os._name=="nt":
@@ -105,8 +106,6 @@
             import zip_pkg
             self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
 
-    @unittest.skipIf(is_jython, "FIXME: not working on Jython")
-    # Failure possibly due to sys.path not passing to sub-process in test_doctest.
     def test_doctest_issue4197(self):
         # To avoid having to keep two copies of the doctest module's
         # unit tests in sync, this test works by taking the source of
@@ -121,16 +120,26 @@
                                     "test_zipped_doctest")
         test_src = test_src.replace("test.sample_doctest",
                                     "sample_zipped_doctest")
-        sample_src = inspect.getsource(sample_doctest)
-        sample_src = sample_src.replace("test.test_doctest",
-                                        "test_zipped_doctest")
+        # The sample doctest files rewritten to include in the zipped version.
+        sample_sources = {}
+        for mod in [sample_doctest, sample_doctest_no_doctests,
+                    sample_doctest_no_docstrings]:
+            src = inspect.getsource(mod)
+            src = src.replace("test.test_doctest", "test_zipped_doctest")
+            # Rewrite the module name so that, for example,
+            # "test.sample_doctest" becomes "sample_zipped_doctest".
+            mod_name = mod.__name__.split(".")[-1]
+            mod_name = mod_name.replace("sample_", "sample_zipped_")
+            sample_sources[mod_name] = src
+
         with temp_dir() as d:
             script_name = make_script(d, 'test_zipped_doctest',
                                             test_src)
             zip_name, run_name = make_zip_script(d, 'test_zip',
                                                 script_name)
             z = zipfile.ZipFile(zip_name, 'a')
-            z.writestr("sample_zipped_doctest.py", sample_src)
+            for mod_name, src in sample_sources.items():
+                z.writestr(mod_name + ".py", src)
             z.close()
             if verbose:
                 zip_file = zipfile.ZipFile(zip_name, 'r')
@@ -190,9 +199,10 @@
                 test_zipped_doctest.test_unittest_reportflags,
             ]
             # Needed for test_DocTestParser and test_debug
-            deprecations = [
+            deprecations = []
+            if __debug__:
                 # Ignore all warnings about the use of class Tester in this module.
-                ("class Tester is deprecated", DeprecationWarning)]
+                deprecations.append(("class Tester is deprecated", DeprecationWarning))
             if sys.py3kwarning:
                 deprecations += [
                     ("backquote not supported", SyntaxWarning),
@@ -201,7 +211,6 @@
                 for obj in known_good_tests:
                     _run_object_doctest(obj, test_zipped_doctest)
 
-    @unittest.skipIf(is_jython, "FIXME: not working on Jython")
     def test_doctest_main_issue4197(self):
         test_src = textwrap.dedent("""\
                     class Test:
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@
 Jython 2.7rc3
   Bugs fixed
    - [ 2326 ] Java's weakly consistent iteration of ConcurrentMap is compatible with mutation
+   - [ 1572 ] sys-package-mgr console messages silenced by default. Thanks to Emmanuel Jannetti.
+   - [ 2332 ] jython -m test.regrtest -e now finds the tests it should.
 
 Jython 2.7rc2
   Bugs fixed
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -929,7 +929,10 @@
         <!-- Clean any old test output -->
         <delete dir="${junit.reports}"/>
     </target>
-    <target name="javatest" depends="developer-build" description="run all the JUnit tests">
+    <target name="javatest" depends="javatest-basepath,importest"
+            description="run all the JUnit tests">
+    </target>
+    <target name="javatest-basepath" depends="developer-build">
         <mkdir dir="${junit.reports}"/>
         <junit fork="true" printsummary="true">
             <formatter type="xml"/>
@@ -942,6 +945,7 @@
                     <exclude name="**/InterpTestCase.java" />
                     <exclude name="**/jythonTest*" /> <!-- Must run interactively -->
                     <exclude name="org/python/antlr/**" />
+                    <exclude name="org/python/tests/imp/**" /> <!-- See importest -->
                     <exclude name=".classpath" />
                     <exclude name=".project" />
                 </fileset>
diff --git a/src/org/python/core/packagecache/CachedJarsPackageManager.java b/src/org/python/core/packagecache/CachedJarsPackageManager.java
--- a/src/org/python/core/packagecache/CachedJarsPackageManager.java
+++ b/src/org/python/core/packagecache/CachedJarsPackageManager.java
@@ -272,7 +272,7 @@
 
                 if ((entry == null || !(new File(entry.cachefile).exists()))
                         && cache) {
-                    message("processing new jar, '" + jarcanon + "'");
+                    comment("processing new jar, '" + jarcanon + "'");
 
                     String jarname;
                     if (localfile) {
@@ -303,7 +303,7 @@
                 if (caching) {
                     this.indexModified = true;
                     if (entry.mtime != 0) {
-                        message("processing modified jar, '" + jarcanon + "'");
+                        comment("processing modified jar, '" + jarcanon + "'");
                     }
                     entry.mtime = mtime;
                 }

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list