/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Merge from integration, mode-changes are broken.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
import bzrlib.iterablefile
36
36
import bzrlib.merge3
37
37
import bzrlib.osutils
 
38
import bzrlib.osutils as osutils
38
39
import bzrlib.plugin
39
40
import bzrlib.store
40
41
import bzrlib.trace
99
100
        # at the end
100
101
        SHOW_DESCRIPTIONS = False
101
102
        if self.showAll:
102
 
            width = bzrlib.osutils.terminal_width()
 
103
            width = osutils.terminal_width()
103
104
            name_width = width - 15
104
105
            what = None
105
106
            if SHOW_DESCRIPTIONS:
259
260
            return
260
261
        raise AssertionError("texts not equal:\n" + 
261
262
                             self._ndiff_strings(a, b))      
 
263
        
 
264
    def assertStartsWith(self, s, prefix):
 
265
        if not s.startswith(prefix):
 
266
            raise AssertionError('string %r does not start with %r' % (s, prefix))
 
267
 
 
268
    def assertEndsWith(self, s, suffix):
 
269
        if not s.endswith(prefix):
 
270
            raise AssertionError('string %r does not end with %r' % (s, suffix))
262
271
 
263
272
    def assertContainsRe(self, haystack, needle_re):
264
273
        """Assert that a contains something matching a regular expression."""
530
539
                else:
531
540
                    raise
532
541
            # successfully created
533
 
            TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
 
542
            TestCaseInTempDir.TEST_ROOT = osutils.abspath(root)
534
543
            break
535
544
        # make a fake bzr directory there to prevent any tests propagating
536
545
        # up onto the source directory's real branch
537
 
        os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
 
546
        os.mkdir(osutils.pathjoin(TestCaseInTempDir.TEST_ROOT, '.bzr'))
538
547
 
539
548
    def setUp(self):
540
549
        super(TestCaseInTempDir, self).setUp()
542
551
        _currentdir = os.getcwdu()
543
552
        short_id = self.id().replace('bzrlib.tests.', '') \
544
553
                   .replace('__main__.', '')
545
 
        self.test_dir = os.path.join(self.TEST_ROOT, short_id)
 
554
        self.test_dir = osutils.pathjoin(self.TEST_ROOT, short_id)
546
555
        os.mkdir(self.test_dir)
547
556
        os.chdir(self.test_dir)
548
557
        os.environ['HOME'] = self.test_dir
 
558
        os.environ['APPDATA'] = self.test_dir
549
559
        def _leaveDirectory():
550
560
            os.chdir(_currentdir)
551
561
        self.addCleanup(_leaveDirectory)
582
592
 
583
593
    def failUnlessExists(self, path):
584
594
        """Fail unless path, which may be abs or relative, exists."""
585
 
        self.failUnless(bzrlib.osutils.lexists(path))
 
595
        self.failUnless(osutils.lexists(path))
 
596
 
 
597
    def failIfExists(self, path):
 
598
        """Fail if path, which may be abs or relative, exists."""
 
599
        self.failIf(osutils.lexists(path))
586
600
        
587
601
    def assertFileEqual(self, content, path):
588
602
        """Fail if path does not contain 'content'."""
589
 
        self.failUnless(bzrlib.osutils.lexists(path))
 
603
        self.failUnless(osutils.lexists(path))
590
604
        self.assertEqualDiff(content, open(path, 'r').read())
591
 
        
 
605
 
592
606
 
593
607
def filter_suite_by_re(suite, pattern):
594
608
    result = TestSuite()
642
656
                   'bzrlib.tests.test_annotate',
643
657
                   'bzrlib.tests.test_api',
644
658
                   'bzrlib.tests.test_bad_files',
 
659
                   'bzrlib.tests.test_basis_inventory',
645
660
                   'bzrlib.tests.test_branch',
646
661
                   'bzrlib.tests.test_command',
647
662
                   'bzrlib.tests.test_commit',
665
680
                   'bzrlib.tests.test_msgeditor',
666
681
                   'bzrlib.tests.test_nonascii',
667
682
                   'bzrlib.tests.test_options',
 
683
                   'bzrlib.tests.test_osutils',
668
684
                   'bzrlib.tests.test_parent',
 
685
                   'bzrlib.tests.test_permissions',
669
686
                   'bzrlib.tests.test_plugins',
670
687
                   'bzrlib.tests.test_remove',
671
688
                   'bzrlib.tests.test_revision',
677
694
                   'bzrlib.tests.test_sampler',
678
695
                   'bzrlib.tests.test_selftest',
679
696
                   'bzrlib.tests.test_setup',
680
 
                   'bzrlib.tests.test_sftp',
 
697
                   'bzrlib.tests.test_sftp_transport',
681
698
                   'bzrlib.tests.test_smart_add',
682
699
                   'bzrlib.tests.test_source',
683
700
                   'bzrlib.tests.test_status',
696
713
                   'bzrlib.tests.test_xml',
697
714
                   ]
698
715
 
699
 
    print '%10s: %s' % ('bzr', os.path.realpath(sys.argv[0]))
 
716
    TestCase.BZRPATH = osutils.pathjoin(
 
717
            osutils.realpath(osutils.dirname(bzrlib.__path__[0])), 'bzr')
 
718
    print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
700
719
    print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
701
720
    print
702
721
    suite = TestSuite()