[patch] test_source should avoid walking into temporary directories

Martin Pool mbp at canonical.com
Tue Oct 31 04:31:58 GMT 2006


As the subject says.  If you happen to have several old test  
directories around it can take a long time or cause spurious  
failures.  (We sometimes create sample files called *.py).

=== modified file 'bzrlib/tests/test_source.py'
--- bzrlib/tests/test_source.py	2006-10-18 04:45:50 +0000
+++ bzrlib/tests/test_source.py	2006-10-31 04:28:50 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005, 2006 Canonical Ltd
#   Authors: Robert Collins <robert.collins at canonical.com>
#
# This program is free software; you can redistribute it and/or modify
@@ -114,6 +114,9 @@
          yield bzr_path
          for root, dirs, files in os.walk(bzrlib_dir):
+            for d in dirs:
+                if d.endswith('.tmp'):
+                    dirs.remove(d)
              for f in files:
                  if not f.endswith('.py'):
                      continue
@@ -154,6 +157,14 @@
          return False
+    def test_tmpdir_not_in_source_files(self):
+        """When scanning for source files, we don't descend test  
tempdirs"""
+        for filename in self.get_source_files():
+            if re.search(r'test....\.tmp', filename):
+                self.fail("get_source_file() returned filename %r "
+                          "from within a temporary directory"
+                          % filename)
+
      def test_copyright(self):
          """Test that all .py files have a valid copyright statement"""
          # These are files which contain a different copyright  
statement


-- 
Martin







More information about the bazaar mailing list