Rev 5932: Merge trunk resolving news conflict in file:///home/vila/src/bzr/bugs/787942-osx-normalizes/

Vincent Ladeuil v.ladeuil+lp at free.fr
Sat May 28 15:41:39 UTC 2011


At file:///home/vila/src/bzr/bugs/787942-osx-normalizes/

------------------------------------------------------------
revno: 5932 [merge]
revision-id: v.ladeuil+lp at free.fr-20110528154139-fdxnfx42f6kfmotd
parent: v.ladeuil+lp at free.fr-20110528145633-2i7olnfhw5urdxwc
parent: pqm at pqm.ubuntu.com-20110528072339-sz8zc51i8sv71lgx
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 787942-osx-normalizes
timestamp: Sat 2011-05-28 17:41:39 +0200
message:
  Merge trunk resolving news conflict
added:
  bzrlib/i18n.py                 i18n.py-20110429130428-eblvodng604h3dzi-1
  bzrlib/tests/test_i18n.py      test_i18n.py-20110517012016-wjj0ai7qrasnj49p-1
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
  bzrlib/tests/test_trace.py     testtrace.py-20051110225523-a21117fc7a07eeff
  bzrlib/tests/test_utextwrap.py test_utextwrap.py-20110504151300-vdvrs19wd20a5cy0-1
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
  doc/en/whats-new/whats-new-in-2.4.txt whatsnewin2.4.txt-20110114044330-nipk1og7j729fy89-1
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2011-05-27 11:05:47 +0000
+++ b/bzrlib/builtins.py	2011-05-27 17:57:23 +0000
@@ -3691,10 +3691,10 @@
                      Option('randomize', type=str, argname="SEED",
                             help='Randomize the order of tests using the given'
                                  ' seed or "now" for the current time.'),
-                     Option('exclude', type=str, argname="PATTERN",
-                            short_name='x',
-                            help='Exclude tests that match this regular'
-                                 ' expression.'),
+                     ListOption('exclude', type=str, argname="PATTERN",
+                                short_name='x',
+                                help='Exclude tests that match this regular'
+                                ' expression.'),
                      Option('subunit',
                         help='Output test progress via subunit.'),
                      Option('strict', help='Fail on missing dependencies or '
@@ -3751,6 +3751,10 @@
                 "--benchmark is no longer supported from bzr 2.2; "
                 "use bzr-usertest instead")
         test_suite_factory = None
+        if not exclude:
+            exclude_pattern = None
+        else:
+            exclude_pattern = '(' + '|'.join(exclude) + ')'
         selftest_kwargs = {"verbose": verbose,
                           "pattern": pattern,
                           "stop_on_failure": one,
@@ -3761,7 +3765,7 @@
                           "matching_tests_first": first,
                           "list_only": list_only,
                           "random_seed": randomize,
-                          "exclude_pattern": exclude,
+                          "exclude_pattern": exclude_pattern,
                           "strict": strict,
                           "load_list": load_list,
                           "debug_flags": debugflag,

=== added file 'bzrlib/i18n.py'
--- a/bzrlib/i18n.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/i18n.py	2011-05-27 21:38:33 +0000
@@ -0,0 +1,135 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 Luk���� Lalinsk�� <lalinsky at gmail.com>
+# Copyright (C) 2007,2009 Alexander Belchenko <bialix at ukr.net>
+# Copyright (C) 2011 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# This module is copied from Bazaar Explorer and modified for bzr.
+
+"""i18n and l10n support for Bazaar."""
+
+import gettext as _gettext
+import os
+import sys
+
+_translation = _gettext.NullTranslations()
+
+
+def gettext(message):
+    """Translate message. 
+    
+    :returns: translated message as unicode.
+    """
+    return _translation.ugettext(message)
+
+
+def ngettext(s, p, n):
+    """Translate message based on `n`.
+
+    :returns: translated message as unicode.
+    """
+    return _translation.ungettext(s, p, n)
+
+
+def N_(msg):
+    """Mark message for translation but don't translate it right away."""
+    return msg
+
+
+def gettext_per_paragraph(message):
+    """Translate message per paragraph.
+
+    :returns: concatenated translated message as unicode.
+    """
+    paragraphs = message.split(u'\n\n')
+    ugettext = _translation.ugettext
+    # Be careful not to translate the empty string -- it holds the
+    # meta data of the .po file.
+    return u'\n\n'.join(ugettext(p) if p else u'' for p in paragraphs)
+
+
+def install(lang=None):
+    global _translation
+    if lang is None:
+        lang = _get_current_locale()
+    _translation = _gettext.translation(
+            'bzr',
+            localedir=_get_locale_dir(),
+            languages=lang.split(':'),
+            fallback=True)
+
+
+def uninstall():
+    global _translation
+    _translation = _null_translation
+
+
+def _get_locale_dir():
+    if hasattr(sys, 'frozen'):
+        base = os.path.dirname(
+                unicode(sys.executable, sys.getfilesystemencoding()))
+        return os.path.join(base, u'locale')
+    else:
+        base = os.path.dirname(unicode(__file__, sys.getfilesystemencoding()))
+        dirpath = os.path.realpath(os.path.join(base, u'locale'))
+        if os.path.exists(dirpath):
+            return dirpath
+        else:
+            return '/usr/share/locale'
+
+
+def _check_win32_locale():
+    for i in ('LANGUAGE','LC_ALL','LC_MESSAGES','LANG'):
+        if os.environ.get(i):
+            break
+    else:
+        lang = None
+        import locale
+        try:
+            import ctypes
+        except ImportError:
+            # use only user's default locale
+            lang = locale.getdefaultlocale()[0]
+        else:
+            # using ctypes to determine all locales
+            lcid_user = ctypes.windll.kernel32.GetUserDefaultLCID()
+            lcid_system = ctypes.windll.kernel32.GetSystemDefaultLCID()
+            if lcid_user != lcid_system:
+                lcid = [lcid_user, lcid_system]
+            else:
+                lcid = [lcid_user]
+            lang = [locale.windows_locale.get(i) for i in lcid]
+            lang = ':'.join([i for i in lang if i])
+        # set lang code for gettext
+        if lang:
+            os.environ['LANGUAGE'] = lang
+
+
+def _get_current_locale():
+    if not os.environ.get('LANGUAGE'):
+        from bzrlib import config
+        lang = config.GlobalConfig().get_user_option('language')
+        if lang:
+            os.environ['LANGUAGE'] = lang
+            return lang
+    if sys.platform == 'win32':
+        _check_win32_locale()
+    for i in ('LANGUAGE','LC_ALL','LC_MESSAGES','LANG'):
+        lang = os.environ.get(i)
+        if lang:
+            return lang
+    return None

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2011-05-27 02:22:45 +0000
+++ b/bzrlib/tests/__init__.py	2011-05-27 21:41:02 +0000
@@ -3808,6 +3808,7 @@
         'bzrlib.tests.test_http',
         'bzrlib.tests.test_http_response',
         'bzrlib.tests.test_https_ca_bundle',
+        'bzrlib.tests.test_i18n',
         'bzrlib.tests.test_identitymap',
         'bzrlib.tests.test_ignores',
         'bzrlib.tests.test_index',

=== added file 'bzrlib/tests/test_i18n.py'
--- a/bzrlib/tests/test_i18n.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/test_i18n.py	2011-05-27 06:37:07 +0000
@@ -0,0 +1,93 @@
+# Copyright (C) 2011 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Tests for bzrlib.i18n"""
+
+from bzrlib import i18n, tests
+
+
+
+
+class ZzzTranslations(object):
+    """Special Zzz translation for debugging i18n stuff.
+
+    This class can be used to confirm that the message is properly translated
+    during black box tests.
+    """
+    _null_translation = i18n._gettext.NullTranslations()
+
+    def zzz(self, s):
+        return u'zz{{%s}}' % s
+
+    def ugettext(self, s):
+        return self.zzz(self._null_translation.ugettext(s))
+
+    def ungettext(self, s, p, n):
+        return self.zzz(self._null_translation.ungettext(s, p, n))
+
+
+class TestZzzTranslation(tests.TestCase):
+
+    def _check_exact(self, expected, source):
+        self.assertEqual(expected, source)
+        self.assertEqual(type(expected), type(source))
+
+    def test_translation(self):
+        trans = ZzzTranslations()
+
+        t = trans.zzz('msg')
+        self._check_exact(u'zz{{msg}}', t)
+
+        t = trans.ugettext('msg')
+        self._check_exact(u'zz{{msg}}', t)
+
+        t = trans.ungettext('msg1', 'msg2', 0)
+        self._check_exact(u'zz{{msg2}}', t)
+        t = trans.ungettext('msg1', 'msg2', 2)
+        self._check_exact(u'zz{{msg2}}', t)
+
+        t = trans.ungettext('msg1', 'msg2', 1)
+        self._check_exact(u'zz{{msg1}}', t)
+
+
+class TestGetText(tests.TestCase):
+
+    def setUp(self):
+        super(TestGetText, self).setUp()
+        self.overrideAttr(i18n, '_translation', ZzzTranslations())
+
+    def test_oneline(self):
+        self.assertEqual(u"zz{{spam ham eggs}}",
+                         i18n.gettext("spam ham eggs"))
+
+    def test_multiline(self):
+        self.assertEqual(u"zz{{spam\nham\n\neggs\n}}",
+                         i18n.gettext("spam\nham\n\neggs\n"))
+
+
+class TestGetTextPerParagraph(tests.TestCase):
+
+    def setUp(self):
+        super(TestGetTextPerParagraph, self).setUp()
+        self.overrideAttr(i18n, '_translation', ZzzTranslations())
+
+    def test_oneline(self):
+        self.assertEqual(u"zz{{spam ham eggs}}",
+                         i18n.gettext_per_paragraph("spam ham eggs"))
+
+    def test_multiline(self):
+        self.assertEqual(u"zz{{spam\nham}}\n\nzz{{eggs\n}}",
+                         i18n.gettext_per_paragraph("spam\nham\n\neggs\n"))

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2011-05-26 08:05:45 +0000
+++ b/bzrlib/tests/test_selftest.py	2011-05-27 13:49:19 +0000
@@ -3522,3 +3522,40 @@
         self.assertDocTestStringFails(doctest.DocTestSuite, test)
         # tests.DocTestSuite sees None
         self.assertDocTestStringSucceds(tests.IsolatedDocTestSuite, test)
+
+
+class TestSelftestExcludePatterns(tests.TestCase):
+
+    def setUp(self):
+        super(TestSelftestExcludePatterns, self).setUp()
+        self.overrideAttr(tests, 'test_suite', self.suite_factory)
+
+    def suite_factory(self, keep_only=None, starting_with=None):
+        """A test suite factory with only a few tests."""
+        class Test(tests.TestCase):
+            def id(self):
+                # We don't need the full class path
+                return self._testMethodName
+            def a(self):
+                pass
+            def b(self):
+                pass
+            def c(self):
+                pass
+        return TestUtil.TestSuite([Test("a"), Test("b"), Test("c")])
+
+    def assertTestList(self, expected, *selftest_args):
+        # We rely on setUp installing the right test suite factory so we can
+        # test at the command level without loading the whole test suite
+        out, err = self.run_bzr(('selftest', '--list') + selftest_args)
+        actual = out.splitlines()
+        self.assertEquals(expected, actual)
+
+    def test_full_list(self):
+        self.assertTestList(['a', 'b', 'c'])
+
+    def test_single_exclude(self):
+        self.assertTestList(['b', 'c'], '-x', 'a')
+
+    def test_mutiple_excludes(self):
+        self.assertTestList(['c'], '-x', 'a', '-x', 'b')

=== modified file 'bzrlib/tests/test_trace.py'
--- a/bzrlib/tests/test_trace.py	2011-04-07 11:23:09 +0000
+++ b/bzrlib/tests/test_trace.py	2011-05-27 20:46:01 +0000
@@ -128,6 +128,18 @@
         #                with errno, function name, and locale error message
         self.assertContainsRe(msg,
             r"^bzr: ERROR: \(2, 'RemoveDirectory[AW]?', .*\)")
+            
+    def test_format_sockets_error(self):
+        try:
+            import socket
+            sock = socket.socket()
+            sock.send("This should fail.")
+        except socket.error:
+            pass
+        msg = _format_exception()
+        
+        self.assertNotContainsRe(msg,
+            r"Traceback (most recent call last):")
 
     def test_format_unicode_error(self):
         try:

=== modified file 'bzrlib/tests/test_utextwrap.py'
--- a/bzrlib/tests/test_utextwrap.py	2011-05-14 14:59:06 +0000
+++ b/bzrlib/tests/test_utextwrap.py	2011-05-28 06:44:01 +0000
@@ -17,8 +17,12 @@
 
 """Tests of the bzrlib.utextwrap."""
 
-from bzrlib import tests, utextwrap
-from bzrlib.tests import TestSkipped
+from bzrlib import (
+    tests,
+    utextwrap,
+    )
+from bzrlib.tests import features
+
 
 # Japanese "Good morning".
 # Each character have double width. So total 8 width on console.
@@ -167,6 +171,16 @@
 
 
     def setup_both(testcase, base_class, reused_class):
+
+        if (features.sphinx.available()):
+            # Until https://bitbucket.org/birkenfeld/sphinx/issue/706 is fixed,
+            # we can't run these tests when sphinx <= 1.0.1 as it breaks
+            # textwrap.TextWrapper.wordsep_re
+            version = tuple(map(int,
+                                features.sphinx.module.__version__.split('.')))
+            if version <= (1, 0, 7):
+                raise tests.TestSkipped(
+                    'sphinx textwrap monkeypatch breaks utextwrap')
         super(base_class, testcase).setUp()
         override_textwrap_symbols(testcase)
         reused_class.setUp(testcase)
@@ -194,14 +208,14 @@
     class TestWrap(tests.TestCase):
 
         def test_wrap(self):
-            raise TestSkipped("test.test_textwrap is not avialable.")
+            raise tests.TestSkipped("test.test_textwrap is not available.")
 
     class TestLongWord(tests.TestCase):
 
         def test_longword(self):
-            raise TestSkipped("test.test_textwrap is not avialable.")
+            raise tests.TestSkipped("test.test_textwrap is not available.")
 
     class TestIndent(tests.TestCase):
 
         def test_indent(self):
-            raise TestSkipped("test.test_textwrap is not avialable.")
+            raise tests.TestSkipped("test.test_textwrap is not available.")

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-05-28 09:52:37 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-05-28 15:41:39 +0000
@@ -86,6 +86,12 @@
 
 * Fix spurious test failure on OSX for WorkingTreeFormat2.
   (Vincent Ladeuil, #787942)
+* Skip ``utextwrap`` tests when ``sphinx`` breaks text_wrap by an hostile
+  monkeypatch to textwrap.TextWrapper.wordsep_re.
+  (Vincent Ladeuil, #785098)
+
+* Multiple ``selftest --exclude`` options are now combined instead of
+  overriding each other. (Vincent Ladeuil, #746991)
 
 bzr 2.4b3
 #########

=== modified file 'doc/en/whats-new/whats-new-in-2.4.txt'
--- a/doc/en/whats-new/whats-new-in-2.4.txt	2011-05-17 14:42:13 +0000
+++ b/doc/en/whats-new/whats-new-in-2.4.txt	2011-05-27 15:02:17 +0000
@@ -101,6 +101,13 @@
 network roundtrips.  Other operations where a local branch is stacked on a
 branch hosted on a smart server will also benefit.
 
+Testing
+*******
+
+The ``selftest --exclude`` option can now be specified multiple times and
+the tests that match any of the specified patterns will be excluded. Only
+the last specified patetrn was previously taken into account.
+
 Further information
 *******************
 



More information about the bazaar-commits mailing list