~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-01-11 16:12:29 UTC
  • mfrom: (2229.1.1 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070111161229-759760c90ec737e6
(Vincent Ladeuil) Clean up TestCaseWithMemoryTransport

Show diffs side-by-side

added added

removed removed

Lines of Context:
1262
1262
        self.transport_server = default_transport
1263
1263
        self.transport_readonly_server = None
1264
1264
 
1265
 
    def failUnlessExists(self, path):
1266
 
        """Fail unless path, which may be abs or relative, exists."""
1267
 
        self.failUnless(osutils.lexists(path))
1268
 
 
1269
 
    def failIfExists(self, path):
1270
 
        """Fail if path, which may be abs or relative, exists."""
1271
 
        self.failIf(osutils.lexists(path))
1272
 
        
1273
1265
    def get_transport(self):
1274
1266
        """Return a writeable transport for the test scratch space"""
1275
1267
        t = get_transport(self.get_url())
1531
1523
                elif line_endings == 'native':
1532
1524
                    end = os.linesep
1533
1525
                else:
1534
 
                    raise errors.BzrError('Invalid line ending request %r' % (line_endings,))
 
1526
                    raise errors.BzrError(
 
1527
                        'Invalid line ending request %r' % line_endings)
1535
1528
                content = "contents of %s%s" % (name.encode('utf-8'), end)
1536
 
                # Technically 'put()' is the right command. However, put
1537
 
                # uses an AtomicFile, which requires an extra rename into place
1538
 
                # As long as the files didn't exist in the past, append() will
1539
 
                # do the same thing as put()
1540
 
                # On jam's machine, make_kernel_like_tree is:
1541
 
                #   put:    4.5-7.5s (averaging 6s)
1542
 
                #   append: 2.9-4.5s
1543
 
                #   put_non_atomic: 2.9-4.5s
1544
1529
                transport.put_bytes_non_atomic(urlutils.escape(name), content)
1545
1530
 
1546
1531
    def build_tree_contents(self, shape):
1548
1533
 
1549
1534
    def assertFileEqual(self, content, path):
1550
1535
        """Fail if path does not contain 'content'."""
1551
 
        self.failUnless(osutils.lexists(path))
 
1536
        self.failUnlessExists(path)
1552
1537
        # TODO: jam 20060427 Shouldn't this be 'rb'?
1553
1538
        self.assertEqualDiff(content, open(path, 'r').read())
1554
1539
 
 
1540
    def failUnlessExists(self, path):
 
1541
        """Fail unless path, which may be abs or relative, exists."""
 
1542
        self.failUnless(osutils.lexists(path))
 
1543
 
 
1544
    def failIfExists(self, path):
 
1545
        """Fail if path, which may be abs or relative, exists."""
 
1546
        self.failIf(osutils.lexists(path))
 
1547
 
1555
1548
 
1556
1549
class TestCaseWithTransport(TestCaseInTempDir):
1557
1550
    """A test case that provides get_url and get_readonly_url facilities.