[arch-commits] Commit in bzr/trunk (3 files)

Rémy Oudompheng remy at archlinux.org
Mon Sep 20 12:19:10 UTC 2010


    Date: Monday, September 20, 2010 @ 08:19:09
  Author: remy
Revision: 90977

Patch for python 2.7.

Added:
  bzr/trunk/python2.7-compat.patch
  bzr/trunk/unittest-compat.patch
Modified:
  bzr/trunk/PKGBUILD

------------------------+
 PKGBUILD               |   21 +++-
 python2.7-compat.patch |   40 ++++++++
 unittest-compat.patch  |  229 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 285 insertions(+), 5 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2010-09-19 22:44:17 UTC (rev 90976)
+++ PKGBUILD	2010-09-20 12:19:09 UTC (rev 90977)
@@ -3,22 +3,33 @@
 
 pkgname=bzr
 pkgver=2.1.2
-pkgrel=1
+pkgrel=2
 pkgdesc="A decentralized revision control system (bazaar)"
 arch=('i686' 'x86_64')
 url="http://www.bazaar-vcs.org"
 license=('GPL')
-depends=('python')
-source=(http://launchpad.net/bzr/2.1/${pkgver}/+download/${pkgname}-${pkgver}.tar.gz)
-md5sums=('834d18558b7f3e0f36e3933f8a177506')
+depends=('python2')
+source=(http://launchpad.net/bzr/2.1/${pkgver}/+download/${pkgname}-${pkgver}.tar.gz
+        unittest-compat.patch
+        python2.7-compat.patch)
+md5sums=('834d18558b7f3e0f36e3933f8a177506'
+         '0f0d8e0d31032cde59565b6c74a37e41')
 
 build() {
   cd ${srcdir}/${pkgname}-${pkgver}
   sed -i 's|man/man1|share/man/man1|' setup.py
-  python setup.py install --prefix=/usr --root=${pkgdir}
+  # https://bugs.launchpad.net/bzr/+bug/612096
+  patch -p0 -i ${srcdir}/python2.7-compat.patch
+  # https://bugs.launchpad.net/bzr/+bug/582113
+  patch -p0 -i ${srcdir}/unittest-compat.patch
+  python2 setup.py install --prefix=/usr --root=${pkgdir}
 
   # bash-completion
   install -D -m644 contrib/bash/bzr ${pkgdir}/etc/bash_completion.d/bzr
   install -D -m644 contrib/bash/bzr.simple \
 		   ${pkgdir}/etc/bash_completion.d/bzr.simple
 }
+
+md5sums=('834d18558b7f3e0f36e3933f8a177506'
+         '34f84b51d8d2c3240f367f2e5d310f5a'
+         '0f0d8e0d31032cde59565b6c74a37e41')

Added: python2.7-compat.patch
===================================================================
--- python2.7-compat.patch	                        (rev 0)
+++ python2.7-compat.patch	2010-09-20 12:19:09 UTC (rev 90977)
@@ -0,0 +1,40 @@
+=== modified file 'bzrlib/transport/http/_urllib2_wrappers.py'
+--- bzrlib/transport/http/_urllib2_wrappers.py	2010-05-08 05:56:28 +0000
++++ bzrlib/transport/http/_urllib2_wrappers.py	2010-09-15 02:43:44 +0000
+@@ -75,6 +75,26 @@
+     )
+ 
+ 
++class addinfourl(urllib2.addinfourl):
++    '''Replacement addinfourl class compatible with python-2.7's xmlrpclib
++
++    In python-2.7, xmlrpclib expects that the response object that it receives
++    has a getheader method.  httplib.HTTPResponse provides this but
++    urllib2.addinfourl does not.  Add the necessary functions here, ported to
++    use the internal data structures of addinfourl.
++    '''
++
++    def getheader(self, name, default=None):
++        if self.headers is None:
++            raise httplib.ResponseNotReady()
++        return self.headers.getheader(name, default)
++
++    def getheaders(self):
++        if self.headers is None:
++            raise httplib.ResponseNotReady()
++        return self.headers.items()
++
++
+ class _ReportingFileSocket(object):
+ 
+     def __init__(self, filesock, report_activity=None):
+@@ -656,7 +676,7 @@
+             r = response
+             r.recv = r.read
+             fp = socket._fileobject(r, bufsize=65536)
+-            resp = urllib2.addinfourl(fp, r.msg, req.get_full_url())
++            resp = addinfourl(fp, r.msg, req.get_full_url())
+             resp.code = r.status
+             resp.msg = r.reason
+             resp.version = r.version
+

Added: unittest-compat.patch
===================================================================
--- unittest-compat.patch	                        (rev 0)
+++ unittest-compat.patch	2010-09-20 12:19:09 UTC (rev 90977)
@@ -0,0 +1,229 @@
+=== modified file 'bzrlib/tests/TestUtil.py'
+--- bzrlib/tests/TestUtil.py	2010-02-17 17:11:16 +0000
++++ bzrlib/tests/TestUtil.py	2010-08-05 18:13:49 +0000
+@@ -135,7 +135,13 @@
+         >>>         result.addTests([test, test])
+         >>>     return result
+         """
+-        basic_tests = super(TestLoader, self).loadTestsFromModule(module)
++        if sys.version_info < (2, 7):
++            basic_tests = super(TestLoader, self).loadTestsFromModule(module)
++        else:
++            # GZ 2010-07-19: Python 2.7 unittest also uses load_tests but with
++            #                a different and incompatible signature
++            basic_tests = super(TestLoader, self).loadTestsFromModule(module,
++                use_load_tests=False)
+         load_tests = getattr(module, "load_tests", None)
+         if load_tests is not None:
+             return load_tests(basic_tests, module, self)
+
+=== modified file 'bzrlib/tests/__init__.py'
+--- bzrlib/tests/__init__.py	2010-08-05 05:41:34 +0000
++++ bzrlib/tests/__init__.py	2010-08-05 18:13:49 +0000
+@@ -141,7 +141,7 @@
+ SUBUNIT_SEEK_CUR = 1
+ 
+ 
+-class ExtendedTestResult(unittest._TextTestResult):
++class ExtendedTestResult(testtools.TextTestResult):
+     """Accepts, reports and accumulates the results of running tests.
+ 
+     Compared to the unittest version this class adds support for
+@@ -168,7 +168,7 @@
+         :param bench_history: Optionally, a writable file object to accumulate
+             benchmark results.
+         """
+-        unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
++        testtools.TextTestResult.__init__(self, stream)
+         if bench_history is not None:
+             from bzrlib.version import _get_bzr_source_tree
+             src_tree = _get_bzr_source_tree()
+@@ -201,11 +201,13 @@
+         actionTaken = "Ran"
+         stopTime = time.time()
+         timeTaken = stopTime - self.startTime
+-        self.printErrors()
+-        self.stream.writeln(self.separator2)
+-        self.stream.writeln("%s %d test%s in %.3fs" % (actionTaken,
++        # GZ 2010-07-19: Seems testtools has no printErrors method, and though
++        #                the parent class method is similar have to duplicate
++        self._show_list('ERROR', self.errors)
++        self._show_list('FAIL', self.failures)
++        self.stream.write(self.sep2)
++        self.stream.write("%s %d test%s in %.3fs\n\n" % (actionTaken,
+                             run, run != 1 and "s" or "", timeTaken))
+-        self.stream.writeln()
+         if not self.wasSuccessful():
+             self.stream.write("FAILED (")
+             failed, errored = map(len, (self.failures, self.errors))
+@@ -218,20 +220,20 @@
+                 if failed or errored: self.stream.write(", ")
+                 self.stream.write("known_failure_count=%d" %
+                     self.known_failure_count)
+-            self.stream.writeln(")")
++            self.stream.write(")\n")
+         else:
+             if self.known_failure_count:
+-                self.stream.writeln("OK (known_failures=%d)" %
++                self.stream.write("OK (known_failures=%d)\n" %
+                     self.known_failure_count)
+             else:
+-                self.stream.writeln("OK")
++                self.stream.write("OK\n")
+         if self.skip_count > 0:
+             skipped = self.skip_count
+-            self.stream.writeln('%d test%s skipped' %
++            self.stream.write('%d test%s skipped\n' %
+                                 (skipped, skipped != 1 and "s" or ""))
+         if self.unsupported:
+             for feature, count in sorted(self.unsupported.items()):
+-                self.stream.writeln("Missing feature '%s' skipped %d tests." %
++                self.stream.write("Missing feature '%s' skipped %d tests.\n" %
+                     (feature, count))
+         if self._strict:
+             ok = self.wasStrictlySuccessful()
+@@ -279,7 +281,7 @@
+         return what
+ 
+     def startTest(self, test):
+-        unittest.TestResult.startTest(self, test)
++        super(ExtendedTestResult, self).startTest(test)
+         if self.count == 0:
+             self.startTests()
+         self.report_test_start(test)
+@@ -323,7 +325,7 @@
+         fails with an unexpected error.
+         """
+         self._post_mortem()
+-        unittest.TestResult.addError(self, test, err)
++        super(ExtendedTestResult, self).addError(test, err)
+         self.error_count += 1
+         self.report_error(test, err)
+         if self.stop_early:
+@@ -337,7 +339,7 @@
+         fails because e.g. an assert() method failed.
+         """
+         self._post_mortem()
+-        unittest.TestResult.addFailure(self, test, err)
++        super(ExtendedTestResult, self).addFailure(test, err)
+         self.failure_count += 1
+         self.report_failure(test, err)
+         if self.stop_early:
+@@ -357,7 +359,7 @@
+                     test.id()))
+         self.report_success(test)
+         self._cleanupLogFile(test)
+-        unittest.TestResult.addSuccess(self, test)
++        super(ExtendedTestResult, self).addSuccess(test)
+         test._log_contents = ''
+ 
+     def addExpectedFailure(self, test, err):
+@@ -551,40 +553,40 @@
+         return '%s%s' % (indent, err[1])
+ 
+     def report_error(self, test, err):
+-        self.stream.writeln('ERROR %s\n%s'
++        self.stream.write('ERROR %s\n%s\n'
+                 % (self._testTimeString(test),
+                    self._error_summary(err)))
+ 
+     def report_failure(self, test, err):
+-        self.stream.writeln(' FAIL %s\n%s'
++        self.stream.write(' FAIL %s\n%s\n'
+                 % (self._testTimeString(test),
+                    self._error_summary(err)))
+ 
+     def report_known_failure(self, test, err):
+-        self.stream.writeln('XFAIL %s\n%s'
++        self.stream.write('XFAIL %s\n%s\n'
+                 % (self._testTimeString(test),
+                    self._error_summary(err)))
+ 
+     def report_success(self, test):
+-        self.stream.writeln('   OK %s' % self._testTimeString(test))
++        self.stream.write('   OK %s\n' % self._testTimeString(test))
+         for bench_called, stats in getattr(test, '_benchcalls', []):
+-            self.stream.writeln('LSProf output for %s(%s, %s)' % bench_called)
++            self.stream.write('LSProf output for %s(%s, %s)\n' % bench_called)
+             stats.pprint(file=self.stream)
+         # flush the stream so that we get smooth output. This verbose mode is
+         # used to show the output in PQM.
+         self.stream.flush()
+ 
+     def report_skip(self, test, reason):
+-        self.stream.writeln(' SKIP %s\n%s'
++        self.stream.write(' SKIP %s\n%s\n'
+                 % (self._testTimeString(test), reason))
+ 
+     def report_not_applicable(self, test, reason):
+-        self.stream.writeln('  N/A %s\n    %s'
++        self.stream.write('  N/A %s\n    %s\n'
+                 % (self._testTimeString(test), reason))
+ 
+     def report_unsupported(self, test, feature):
+         """test cannot be run because feature is missing."""
+-        self.stream.writeln("NODEP %s\n    The feature '%s' is not available."
++        self.stream.write("NODEP %s\n    The feature '%s' is not available.\n"
+                 %(self._testTimeString(test), feature))
+ 
+ 
+@@ -619,7 +621,7 @@
+             encode = codec.encode
+         stream = osutils.UnicodeOrBytesToBytesWriter(encode, stream)
+         stream.encoding = new_encoding
+-        self.stream = unittest._WritelnDecorator(stream)
++        self.stream = stream
+         self.descriptions = descriptions
+         self.verbosity = verbosity
+         self._bench_history = bench_history
+
+=== modified file 'bzrlib/tests/test_selftest.py'
+--- bzrlib/tests/test_selftest.py	2010-07-23 18:45:31 +0000
++++ bzrlib/tests/test_selftest.py	2010-08-05 18:13:49 +0000
+@@ -801,7 +801,7 @@
+         self.requireFeature(test_lsprof.LSProfFeature)
+         result_stream = StringIO()
+         result = bzrlib.tests.VerboseTestResult(
+-            unittest._WritelnDecorator(result_stream),
++            result_stream,
+             descriptions=0,
+             verbosity=2,
+             )
+@@ -862,7 +862,7 @@
+         # verbose test output formatting
+         result_stream = StringIO()
+         result = bzrlib.tests.VerboseTestResult(
+-            unittest._WritelnDecorator(result_stream),
++            result_stream,
+             descriptions=0,
+             verbosity=2,
+             )
+@@ -878,6 +878,9 @@
+         output = result_stream.getvalue()[prefix:]
+         lines = output.splitlines()
+         self.assertContainsRe(lines[0], r'XFAIL *\d+ms$')
++        if sys.version_info > (2, 7):
++            self.expectFailure("_ExpectedFailure on 2.7 loses the message",
++                self.assertNotEqual, lines[1], '    ')
+         self.assertEqual(lines[1], '    foo')
+         self.assertEqual(2, len(lines))
+ 
+@@ -917,7 +920,7 @@
+         # verbose test output formatting
+         result_stream = StringIO()
+         result = bzrlib.tests.VerboseTestResult(
+-            unittest._WritelnDecorator(result_stream),
++            result_stream,
+             descriptions=0,
+             verbosity=2,
+             )
+@@ -1419,7 +1422,7 @@
+         sample_test = TestTestCase("method_that_times_a_bit_twice")
+         output_stream = StringIO()
+         result = bzrlib.tests.VerboseTestResult(
+-            unittest._WritelnDecorator(output_stream),
++            output_stream,
+             descriptions=0,
+             verbosity=2)
+         sample_test.run(result)
+




More information about the arch-commits mailing list