Rev 123: Fix selftest failures and catch up with recent bzr.dev modifications. in file:///net/bigmamac/Volumes/home/vila/.bazaar/plugins/xmloutput/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Mar 26 17:41:38 GMT 2009


At file:///net/bigmamac/Volumes/home/vila/.bazaar/plugins/xmloutput/

------------------------------------------------------------
revno: 123
revision-id: v.ladeuil+lp at free.fr-20090326174138-ht0e59nh06z2am7k
parent: guillo.gonzo at gmail.com-20090321213509-gn4pg28jcepd8gy3
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: xmloutput
timestamp: Thu 2009-03-26 18:41:38 +0100
message:
  Fix selftest failures and catch up with recent bzr.dev modifications.
  
  * tests/test_service.py:
  (TestXmlRpcServer.setUp): Call base class setUp.
  
  * tests/test_info_xml.py: 
  Cleanup imports.
  
  * __init__.py:
  (xmllog_options): New helper.
  (cmd_xmllog): Simplified and made more robust against bzr command
  evolutions.
  (load_tests): Allows using -s bp.xmloutput.tests.whatever.
  
  * infoxml.py: 
  Delete obsolete and unused imports.
  
  * tests/__init__.py: 
  Delete obsolete and unused imports.
  (ExternalBase.runbzr): Delete obsolete and unused method.
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2009-02-15 22:14:12 +0000
+++ b/__init__.py	2009-03-26 17:41:38 +0000
@@ -43,7 +43,6 @@
     errors
     )
 
-from bzrlib.workingtree import WorkingTree
 from bzrlib.option import Option, custom_help
 from bzrlib.commands import display_command, register_command
 import logxml
@@ -56,7 +55,8 @@
 version_info = (0, 8, 3)
 plugin_name = 'xmloutput'
 
-null_option = Option('null', help='Write an ascii NUL (\\0) as the final char.')
+null_option = option.Option('null',
+                            help='Write an ascii NUL (\\0) as the final char.')
 
 
 class cmd_xmlstatus(commands.Command):
@@ -312,48 +312,31 @@
         to_file.write('\n')
 
 
+def xmllog_options():
+    opts = builtins.cmd_log.takes_options
+    opts.append(null_option)
+    # Remove log_format since we requires our own
+    opts.remove('log-format')
+    return opts
+
+
 class cmd_xmllog(builtins.cmd_log):
     """Show log of a branch, file, or directory as XML."""
     hidden = True
-    takes_args = ['location?']
-    takes_options = [
-            Option('forward',
-                   help='Show from oldest to newest.'),
-            Option('timezone',
-                   type=str,
-                   help='Display timezone as local, original, or utc.'),
-            custom_help('verbose',
-                   help='Show files changed in each revision.'),
-            'show-ids',
-            'revision',
-            Option('message',
-                   short_name='m',
-                   help='Show revisions whose message matches this '
-                        'regular expression.',
-                   type=str),
-            Option('limit',
-                   short_name='l',
-                   help='Limit the output to the first N revisions.',
-                   argname='N',
-                   type=bzrlib.builtins._parse_limit),
-            null_option
-            ]
-    encoding_type = 'replace'
+
+    takes_options = xmllog_options()
 
     @display_command
     @handle_error_xml
-    def run(self, location=None, timezone='original',
-            verbose=False,
-            show_ids=False,
-            forward=False,
-            revision=None,
-            message=None,
-            limit=None,
-            null=False):
-        exit_val =  builtins.cmd_log.run(self, location=location,
-            timezone=timezone, verbose=verbose, show_ids=show_ids,
-            forward=forward, revision=revision,
-            log_format=logxml.XMLLogFormatter, message=message, limit=limit)
+    def run(self, *args, **kwargs):
+        # Force our specific formatter
+        kwargs['log_format'] = logxml.XMLLogFormatter
+        # Filter out our specific option
+        try:
+            null = kwargs.pop('null')
+        except KeyError:
+            null = False
+        exit_val =  builtins.cmd_log.run(self, *args, **kwargs)
         if null:
             self.outf.write('\0')
         self.outf.write('\n')
@@ -464,7 +447,10 @@
                               'Detailed XML log format')
 
 
-def test_suite():
-    import tests
-    return tests.test_suite()
-
+def load_tests(basic_tests, module, loader):
+    testmod_names = [
+        'tests',
+        ]
+    basic_tests.addTest(loader.loadTestsFromModuleNames(
+            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
+    return basic_tests

=== modified file 'infoxml.py'
--- a/infoxml.py	2008-07-19 19:26:59 +0000
+++ b/infoxml.py	2009-03-26 17:41:38 +0000
@@ -41,8 +41,7 @@
 
 from bzrlib.errors import (NoWorkingTree, NotBranchError,
                            NoRepositoryPresent, NotLocalUrl)
-from bzrlib.symbol_versioning import (deprecated_function,
-        zero_eighteen)
+
 
 def get_lines_xml(self):
     return ["<%s>%s</%s>" % (l.replace(' ', '_'), u, l.replace(' ', '_')) for l, u in self.locs ]

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2009-03-09 11:51:11 +0000
+++ b/tests/__init__.py	2009-03-26 17:41:38 +0000
@@ -19,46 +19,19 @@
 
 import sys
 
-from bzrlib.tests import (
-    TestCaseWithTransport,
-    TestLoader,
-    )
-from bzrlib.symbol_versioning import (
-    deprecated_method,
-    zero_eighteen,
-    )
-import bzrlib.ui as ui
-
-
-def test_suite():
+
+from bzrlib import tests
+
+
+def load_tests(basic_tests, module, loader):
     testmod_names = [
-                     'test_version_xml',
-                     'test_status_xml',
-                     'test_log_xml',
-                     'test_annotate_xml',
-                     'test_info_xml',
-                     'test_service',
-                     ]
-    
-    loader = TestLoader()
-#    suite = loader.loadTestsFromModuleNames(testmod_names) 
-    suite = loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i) for i in testmod_names])
-
-    return suite
-
-
-class ExternalBase(TestCaseWithTransport):
-
-    @deprecated_method(zero_eighteen)
-    def runbzr(self, args, retcode=0):
-        if isinstance(args, basestring):
-            args = args.split()
-        return self.run_bzr(args, retcode=retcode)
-
-    def check_output(self, output, *args):
-        """Verify that the expected output matches what bzr says.
-
-        The output is supplied first, so that you can supply a variable
-        number of arguments to bzr.
-        """
-        self.assertEquals(self.run_bzr(*args)[0], output)
+        'test_version_xml',
+        'test_status_xml',
+        'test_log_xml',
+        'test_annotate_xml',
+        'test_info_xml',
+        'test_service',
+        ]
+    basic_tests.addTest(loader.loadTestsFromModuleNames(
+            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
+    return basic_tests

=== modified file 'tests/test_info_xml.py'
--- a/tests/test_info_xml.py	2008-12-17 14:02:30 +0000
+++ b/tests/test_info_xml.py	2009-03-26 17:41:38 +0000
@@ -26,15 +26,14 @@
     errors,
     osutils,
     repository,
+    tests,
     urlutils,
     upgrade,
     )
-from bzrlib.osutils import format_date
-from bzrlib.tests import TestSkipped
-from bzrlib.tests.blackbox import ExternalBase
-
-
-class TestInfoXml(ExternalBase):
+from bzrlib.tests import blackbox
+
+
+class TestInfoXml(blackbox.ExternalBase):
 
     def test_info_non_existing(self):
         if sys.platform == "win32":
@@ -46,7 +45,8 @@
         self.assertEqual('<?xml version="1.0" encoding="%s"?><error>'
                 '<class>NotBranchError</class><dict><key>path</key><value>'
                 '%s</value></dict><message>Not a branch: "%s".</message>'
-                '</error>' % (bzrlib.user_encoding, location, location), err)
+                '</error>' % (osutils.get_user_encoding(),
+                              location, location), err)
 
     def test_info_standalone(self):
         transport = self.get_transport()
@@ -113,7 +113,7 @@
         self.assertEqual('', err)
         tree1.commit('commit one')
         rev = branch1.repository.get_revision(branch1.revision_history()[0])
-        datestring_first = format_date(rev.timestamp, rev.timezone)
+        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
 
         # Branch standalone with push location
         branch2 = branch1.bzrdir.sprout('branch').open_branch()
@@ -345,7 +345,7 @@
         tree1.add('b')
         tree1.commit('commit two')
         rev = branch1.repository.get_revision(branch1.revision_history()[-1])
-        datestring_last = format_date(rev.timestamp, rev.timezone)
+        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
 
         # Out of date branched standalone branch will not be detected
         out, err = self.run_bzr('xmlinfo -v branch')
@@ -664,7 +664,7 @@
         tree2.add('a')
         tree2.commit('commit one')
         rev = repo.get_revision(branch2.revision_history()[0])
-        datestring_first = format_date(rev.timestamp, rev.timezone)
+        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
         out, err = self.run_bzr('xmlinfo tree/lightcheckout --verbose')
         expected_xml = '''<?xml version="1.0"?>
 <info>
@@ -815,7 +815,7 @@
 
         # Out of date lightweight checkout
         rev = repo.get_revision(branch1.revision_history()[-1])
-        datestring_last = format_date(rev.timestamp, rev.timezone)
+        datestring_last = osutils.format_date(rev.timestamp, rev.timezone)
         out, err = self.run_bzr('xmlinfo tree/lightcheckout --verbose')
         expected_xml = '''<?xml version="1.0"?>
 <info>
@@ -1020,7 +1020,7 @@
         tree1.add('a')
         tree1.commit('commit one')
         rev = repo.get_revision(branch1.revision_history()[0])
-        datestring_first = format_date(rev.timestamp, rev.timezone)
+        datestring_first = osutils.format_date(rev.timestamp, rev.timezone)
         out, err = self.run_bzr('xmlinfo -v repo/branch1')
         expected_xml = '''<?xml version="1.0"?>
 <info>
@@ -1528,7 +1528,7 @@
 
     def test_info_locking_oslocks(self):
         if sys.platform == "win32":
-            raise TestSkipped("don't use oslocks on win32 in unix manner")
+            raise tests.TestSkipped("don't use oslocks on win32 in unix manner")
 
         tree = self.make_branch_and_tree('branch',
                                          format=bzrlib.bzrdir.BzrDirFormat6())

=== modified file 'tests/test_log_xml.py'
--- a/tests/test_log_xml.py	2009-02-15 19:43:03 +0000
+++ b/tests/test_log_xml.py	2009-03-26 17:41:38 +0000
@@ -157,8 +157,9 @@
         # should give an error
         wt = self.make_branch_and_tree('.')
         out, err = self.run_bzr('xmllog does-not-exist', retcode=3)
-        self.assertContainsRe(err, 
-                'Path unknown at end or start of revision range: does-not-exist')
+        self.assertContainsRe(
+            err,
+            'Path unknown at end or start of revision range: does-not-exist')
 
     def test_log_with_tags(self):
         tree = self._prepare(format='dirstate-tags')

=== modified file 'tests/test_service.py'
--- a/tests/test_service.py	2008-09-25 01:38:28 +0000
+++ b/tests/test_service.py	2009-03-26 17:41:38 +0000
@@ -122,6 +122,7 @@
     server = None
 
     def setUp(self):
+        tests.TestCase.setUp(self)
         if self.server is None:
             self.server = XMLRPCServer()
             self.server.setUp()



More information about the bazaar-commits mailing list