/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 integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import bzrlib.inventory
35
35
import bzrlib.merge3
36
36
import bzrlib.osutils
 
37
import bzrlib.osutils as osutils
37
38
import bzrlib.plugin
38
39
import bzrlib.store
39
40
import bzrlib.trace
98
99
        # at the end
99
100
        SHOW_DESCRIPTIONS = False
100
101
        if self.showAll:
101
 
            width = bzrlib.osutils.terminal_width()
 
102
            width = osutils.terminal_width()
102
103
            name_width = width - 15
103
104
            what = None
104
105
            if SHOW_DESCRIPTIONS:
258
259
            return
259
260
        raise AssertionError("texts not equal:\n" + 
260
261
                             self._ndiff_strings(a, b))      
 
262
        
 
263
    def assertStartsWith(self, s, prefix):
 
264
        if not s.startswith(prefix):
 
265
            raise AssertionError('string %r does not start with %r' % (s, prefix))
 
266
 
 
267
    def assertEndsWith(self, s, suffix):
 
268
        if not s.endswith(prefix):
 
269
            raise AssertionError('string %r does not end with %r' % (s, suffix))
261
270
 
262
271
    def assertContainsRe(self, haystack, needle_re):
263
272
        """Assert that a contains something matching a regular expression."""
525
534
                else:
526
535
                    raise
527
536
            # successfully created
528
 
            TestCaseInTempDir.TEST_ROOT = os.path.abspath(root)
 
537
            TestCaseInTempDir.TEST_ROOT = osutils.abspath(root)
529
538
            break
530
539
        # make a fake bzr directory there to prevent any tests propagating
531
540
        # up onto the source directory's real branch
532
 
        os.mkdir(os.path.join(TestCaseInTempDir.TEST_ROOT, '.bzr'))
 
541
        os.mkdir(osutils.pathjoin(TestCaseInTempDir.TEST_ROOT, '.bzr'))
533
542
 
534
543
    def setUp(self):
535
544
        super(TestCaseInTempDir, self).setUp()
537
546
        _currentdir = os.getcwdu()
538
547
        short_id = self.id().replace('bzrlib.tests.', '') \
539
548
                   .replace('__main__.', '')
540
 
        self.test_dir = os.path.join(self.TEST_ROOT, short_id)
 
549
        self.test_dir = osutils.pathjoin(self.TEST_ROOT, short_id)
541
550
        os.mkdir(self.test_dir)
542
551
        os.chdir(self.test_dir)
543
552
        os.environ['HOME'] = self.test_dir
 
553
        os.environ['APPDATA'] = self.test_dir
544
554
        def _leaveDirectory():
545
555
            os.chdir(_currentdir)
546
556
        self.addCleanup(_leaveDirectory)
583
593
 
584
594
    def failUnlessExists(self, path):
585
595
        """Fail unless path, which may be abs or relative, exists."""
586
 
        self.failUnless(bzrlib.osutils.lexists(path))
 
596
        self.failUnless(osutils.lexists(path))
 
597
 
 
598
    def failIfExists(self, path):
 
599
        """Fail if path, which may be abs or relative, exists."""
 
600
        self.failIf(osutils.lexists(path))
587
601
        
588
602
    def assertFileEqual(self, content, path):
589
603
        """Fail if path does not contain 'content'."""
590
 
        self.failUnless(bzrlib.osutils.lexists(path))
 
604
        self.failUnless(osutils.lexists(path))
591
605
        self.assertEqualDiff(content, open(path, 'r').read())
592
 
        
 
606
 
593
607
 
594
608
def filter_suite_by_re(suite, pattern):
595
609
    result = TestSuite()
643
657
                   'bzrlib.tests.test_annotate',
644
658
                   'bzrlib.tests.test_api',
645
659
                   'bzrlib.tests.test_bad_files',
 
660
                   'bzrlib.tests.test_basis_inventory',
646
661
                   'bzrlib.tests.test_branch',
647
662
                   'bzrlib.tests.test_command',
648
663
                   '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',
698
715
    test_transport_implementations = [
699
716
        'bzrlib.tests.test_transport_implementations']
700
717
 
701
 
    print '%10s: %s' % ('bzr', os.path.realpath(sys.argv[0]))
 
718
    TestCase.BZRPATH = osutils.pathjoin(
 
719
            osutils.realpath(osutils.dirname(bzrlib.__path__[0])), 'bzr')
 
720
    print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
702
721
    print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
703
722
    print
704
723
    suite = TestSuite()