~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Martin Pool
  • Date: 2006-03-08 03:53:30 UTC
  • mto: This revision was merged to the branch mainline in revision 1602.
  • Revision ID: mbp@sourcefrog.net-20060308035330-40065f85adc9652e
Add new TestCaseWithTransport.assertIsDirectory() and tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
# little as possible, so this should be used rarely if it's added at all.
22
22
# (Suggestion from j-a-meinel, 2005-11-24)
23
23
 
 
24
# NOTE: Some classes in here use camelCaseNaming() rather than
 
25
# underscore_naming().  That's for consistency with unittest; it's not the
 
26
# general style of bzrlib.  Please continue that consistency when adding e.g.
 
27
# new assertFoo() methods.
 
28
 
24
29
import codecs
25
30
from cStringIO import StringIO
26
31
import difflib
791
796
            # TODO: rbc 20060208
792
797
            return WorkingTreeFormat2().initialize(bzrdir.BzrDir.open(relpath))
793
798
 
 
799
    def assertIsDirectory(self, relpath, transport):
 
800
        """Assert that relpath within transport is a directory.
 
801
 
 
802
        This may not be possible on all transports; in that case it propagates
 
803
        a TransportNotPossible.
 
804
        """
 
805
        try:
 
806
            mode = transport.stat(relpath).st_mode
 
807
        except errors.NoSuchFile:
 
808
            self.fail("path %s is not a directory; no such file"
 
809
                      % (relpath))
 
810
        if not stat.S_ISDIR(mode):
 
811
            self.fail("path %s is not a directory; has mode %#o"
 
812
                      % (relpath, mode))
 
813
 
794
814
 
795
815
class ChrootedTestCase(TestCaseWithTransport):
796
816
    """A support class that provides readonly urls outside the local namespace.