Rev 4326: Some cleanups. in file:///home/vila/src/bzr/experimental/log-tests/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue May 5 13:27:07 BST 2009


At file:///home/vila/src/bzr/experimental/log-tests/

------------------------------------------------------------
revno: 4326
revision-id: v.ladeuil+lp at free.fr-20090505122706-hha5brmq94mld5cb
parent: pqm at pqm.ubuntu.com-20090504033314-7mfh3y311028dk2m
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: log-tests
timestamp: Tue 2009-05-05 14:27:06 +0200
message:
  Some cleanups.
  
  * bzrlib/tests/blackbox/test_logformats.py: 
  Fix import, use a proper setUp method.
  
  * bzrlib/tests/test_log.py:
  (LogCatcher.__init__): Fix comment.
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_logformats.py'
--- a/bzrlib/tests/blackbox/test_logformats.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_logformats.py	2009-05-05 12:27:06 +0000
@@ -21,17 +21,34 @@
 
 import os
 
-
-from bzrlib.branch import Branch
-from bzrlib.tests import TestCaseInTempDir
-from bzrlib.config import (ensure_config_dir_exists, config_filename)
-
-
-class TestLogFormats(TestCaseInTempDir):
+from bzrlib import (
+    config,
+    tests,
+    )
+
+
+class TestLogFormats(tests.TestCaseInTempDir):
+
+    def setUp(self):
+        super(TestLogFormats, self).setUp()
+
+        conf_path = config.config_filename()
+        if os.path.isfile(conf_path):
+                # Something is wrong in environment,
+                # we risk overwriting users config
+                self.fail("%s exists" % conf_path)
+
+        config.ensure_config_dir_exists()
+        conf = open(conf_path,'wb')
+        try:
+            conf.write("""[DEFAULT]
+email=Joe Foo <joe at foo.com>
+log_format=line
+""")
+        finally:
+            conf.close()
 
     def test_log_default_format(self):
-        self.setup_config()
-
         self.run_bzr('init')
         open('a', 'wb').write('foo\n')
         self.run_bzr('add a')
@@ -54,13 +71,10 @@
 
         self.run_bzr('commit -m 2')
 
-        # only the lines formatter is this short
         self.assertEquals(7,
             len(self.run_bzr('log --log-format short')[0].split('\n')))
 
     def test_missing_default_format(self):
-        self.setup_config()
-
         os.mkdir('a')
         os.chdir('a')
         self.run_bzr('init')
@@ -87,8 +101,6 @@
         os.chdir('..')
 
     def test_missing_format_arg(self):
-        self.setup_config()
-
         os.mkdir('a')
         os.chdir('a')
         self.run_bzr('init')
@@ -117,7 +129,6 @@
 
     def test_logformat_gnu_changelog(self):
         # from http://launchpad.net/bugs/29582/
-        self.setup_config()
         repo_url = self.make_trivial_history()
 
         out, err = self.run_bzr(
@@ -143,15 +154,3 @@
         bb.finish_series()
         return self.get_url('repo/a')
 
-    def setup_config(self):
-        if os.path.isfile(config_filename()):
-                # Something is wrong in environment,
-                # we risk overwriting users config
-                self.assert_(config_filename() + "exists, abort")
-
-        ensure_config_dir_exists()
-        CONFIG=("[DEFAULT]\n"
-                "email=Joe Foo <joe at foo.com>\n"
-                "log_format=line\n")
-
-        open(config_filename(),'wb').write(CONFIG)

=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py	2009-04-20 08:37:32 +0000
+++ b/bzrlib/tests/test_log.py	2009-05-05 12:27:06 +0000
@@ -45,14 +45,13 @@
 class LogCatcher(log.LogFormatter):
     """Pull log messages into list rather than displaying them.
 
-    For ease of testing we save log messages here rather than actually
-    formatting them, so that we can precisely check the result without
-    being too dependent on the exact formatting.
-
-    We should also test the LogFormatter.
+    For ease of testing we save logged revisions here rather than actually
+    formatting anything, so that we can precisely check the result without
+    being dependent on the exact formatting.
     """
 
     supports_delta = True
+#    supports_merge_revisions = True
 
     def __init__(self):
         super(LogCatcher, self).__init__(to_file=None)



More information about the bazaar-commits mailing list