/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

  • Committer: Martin Pool
  • Date: 2009-11-26 01:42:06 UTC
  • mfrom: (4827 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4828.
  • Revision ID: mbp@sourcefrog.net-20091126014206-qvf8jfpwpro558r4
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
1115
1115
        :raises AssertionError: If the expected and actual stat values differ
1116
1116
            other than by atime.
1117
1117
        """
1118
 
        self.assertEqual(expected.st_size, actual.st_size)
1119
 
        self.assertEqual(expected.st_mtime, actual.st_mtime)
1120
 
        self.assertEqual(expected.st_ctime, actual.st_ctime)
1121
 
        self.assertEqual(expected.st_dev, actual.st_dev)
1122
 
        self.assertEqual(expected.st_ino, actual.st_ino)
1123
 
        self.assertEqual(expected.st_mode, actual.st_mode)
 
1118
        self.assertEqual(expected.st_size, actual.st_size,
 
1119
                         'st_size did not match')
 
1120
        self.assertEqual(expected.st_mtime, actual.st_mtime,
 
1121
                         'st_mtime did not match')
 
1122
        self.assertEqual(expected.st_ctime, actual.st_ctime,
 
1123
                         'st_ctime did not match')
 
1124
        if sys.platform != 'win32':
 
1125
            # On Win32 both 'dev' and 'ino' cannot be trusted. In python2.4 it
 
1126
            # is 'dev' that varies, in python 2.5 (6?) it is st_ino that is
 
1127
            # odd. Regardless we shouldn't actually try to assert anything
 
1128
            # about their values
 
1129
            self.assertEqual(expected.st_dev, actual.st_dev,
 
1130
                             'st_dev did not match')
 
1131
            self.assertEqual(expected.st_ino, actual.st_ino,
 
1132
                             'st_ino did not match')
 
1133
        self.assertEqual(expected.st_mode, actual.st_mode,
 
1134
                         'st_mode did not match')
1124
1135
 
1125
1136
    def assertLength(self, length, obj_with_len):
1126
1137
        """Assert that obj_with_len is of length length."""
2464
2475
        return branchbuilder.BranchBuilder(branch=branch)
2465
2476
 
2466
2477
    def overrideEnvironmentForTesting(self):
2467
 
        os.environ['HOME'] = self.test_home_dir
2468
 
        os.environ['BZR_HOME'] = self.test_home_dir
 
2478
        test_home_dir = self.test_home_dir
 
2479
        if isinstance(test_home_dir, unicode):
 
2480
            test_home_dir = test_home_dir.encode(sys.getfilesystemencoding())
 
2481
        os.environ['HOME'] = test_home_dir
 
2482
        os.environ['BZR_HOME'] = test_home_dir
2469
2483
 
2470
2484
    def setUp(self):
2471
2485
        super(TestCaseWithMemoryTransport, self).setUp()
3321
3335
        if not os.path.isfile(bzr_path):
3322
3336
            # We are probably installed. Assume sys.argv is the right file
3323
3337
            bzr_path = sys.argv[0]
 
3338
        bzr_path = [bzr_path]
 
3339
        if sys.platform == "win32":
 
3340
            # if we're on windows, we can't execute the bzr script directly
 
3341
            bzr_path = [sys.executable] + bzr_path
3324
3342
        fd, test_list_file_name = tempfile.mkstemp()
3325
3343
        test_list_file = os.fdopen(fd, 'wb', 1)
3326
3344
        for test in process_tests:
3327
3345
            test_list_file.write(test.id() + '\n')
3328
3346
        test_list_file.close()
3329
3347
        try:
3330
 
            argv = [bzr_path, 'selftest', '--load-list', test_list_file_name,
 
3348
            argv = bzr_path + ['selftest', '--load-list', test_list_file_name,
3331
3349
                '--subunit']
3332
3350
            if '--no-plugins' in sys.argv:
3333
3351
                argv.append('--no-plugins')
4321
4339
            # Windows doesn't have os.kill, and we catch the SIGBREAK signal.
4322
4340
            # We trigger SIGBREAK via a Console api so we need ctypes to
4323
4341
            # access the function
4324
 
            if not have_ctypes:
 
4342
            try:
 
4343
                import ctypes
 
4344
            except OSError:
4325
4345
                return False
4326
4346
        return True
4327
4347