/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 bzr.dev r3564

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
        elif isinstance(err[1], UnavailableFeature):
219
219
            return self.addNotSupported(test, err[1].args[0])
220
220
        else:
221
 
            self._cleanupLogFile(test)
222
221
            unittest.TestResult.addError(self, test, err)
223
222
            self.error_count += 1
224
223
            self.report_error(test, err)
225
224
            if self.stop_early:
226
225
                self.stop()
 
226
            self._cleanupLogFile(test)
227
227
 
228
228
    def addFailure(self, test, err):
229
229
        """Tell result that test failed.
235
235
        if isinstance(err[1], KnownFailure):
236
236
            return self._addKnownFailure(test, err)
237
237
        else:
238
 
            self._cleanupLogFile(test)
239
238
            unittest.TestResult.addFailure(self, test, err)
240
239
            self.failure_count += 1
241
240
            self.report_failure(test, err)
242
241
            if self.stop_early:
243
242
                self.stop()
 
243
            self._cleanupLogFile(test)
244
244
 
245
245
    def addSuccess(self, test):
246
246
        """Tell result that test completed successfully.
861
861
            return
862
862
        if message is None:
863
863
            message = "texts not equal:\n"
 
864
        if a == b + '\n':
 
865
            message = 'first string is missing a final newline.\n'
 
866
        if a + '\n' == b:
 
867
            message = 'second string is missing a final newline.\n'
864
868
        raise AssertionError(message +
865
869
                             self._ndiff_strings(a, b))
866
870
        
919
923
        """
920
924
        try:
921
925
            list(func(*args, **kwargs))
922
 
        except excClass:
923
 
            return
 
926
        except excClass, e:
 
927
            return e
924
928
        else:
925
929
            if getattr(excClass,'__name__', None) is not None:
926
930
                excName = excClass.__name__
2182
2186
                # the branch is colocated on disk, we cannot create a checkout.
2183
2187
                # hopefully callers will expect this.
2184
2188
                local_controldir= bzrdir.BzrDir.open(self.get_vfs_only_url(relpath))
2185
 
                return local_controldir.create_workingtree()
 
2189
                wt = local_controldir.create_workingtree()
 
2190
                if wt.branch._format != b._format:
 
2191
                    wt._branch = b
 
2192
                    # Make sure that assigning to wt._branch fixes wt.branch,
 
2193
                    # in case the implementation details of workingtree objects
 
2194
                    # change.
 
2195
                    self.assertIs(b, wt.branch)
 
2196
                return wt
2186
2197
            else:
2187
2198
                return b.create_checkout(relpath, lightweight=True)
2188
2199
 
2658
2669
                   'bzrlib.tests.inventory_implementations',
2659
2670
                   'bzrlib.tests.interrepository_implementations',
2660
2671
                   'bzrlib.tests.intertree_implementations',
2661
 
                   'bzrlib.tests.interversionedfile_implementations',
2662
2672
                   'bzrlib.tests.per_lock',
2663
2673
                   'bzrlib.tests.repository_implementations',
2664
 
                   'bzrlib.tests.revisionstore_implementations',
2665
2674
                   'bzrlib.tests.test__dirstate_helpers',
2666
2675
                   'bzrlib.tests.test_ancestry',
2667
2676
                   'bzrlib.tests.test_annotate',
2689
2698
                   'bzrlib.tests.test_directory_service',
2690
2699
                   'bzrlib.tests.test_email_message',
2691
2700
                   'bzrlib.tests.test_errors',
2692
 
                   'bzrlib.tests.test_escaped_store',
2693
2701
                   'bzrlib.tests.test_extract',
2694
2702
                   'bzrlib.tests.test_fetch',
2695
2703
                   'bzrlib.tests.test_filters',
2745
2753
                   'bzrlib.tests.test_registry',
2746
2754
                   'bzrlib.tests.test_remote',
2747
2755
                   'bzrlib.tests.test_repository',
 
2756
                   'bzrlib.tests.per_repository_reference',
2748
2757
                   'bzrlib.tests.test_revert',
2749
2758
                   'bzrlib.tests.test_revision',
2750
2759
                   'bzrlib.tests.test_revisionspec',
2751
2760
                   'bzrlib.tests.test_revisiontree',
2752
2761
                   'bzrlib.tests.test_rio',
 
2762
                   'bzrlib.tests.test_rules',
2753
2763
                   'bzrlib.tests.test_sampler',
2754
2764
                   'bzrlib.tests.test_selftest',
2755
2765
                   'bzrlib.tests.test_setup',
2787
2797
                   'bzrlib.tests.test_versionedfile',
2788
2798
                   'bzrlib.tests.test_version',
2789
2799
                   'bzrlib.tests.test_version_info',
 
2800
                   'bzrlib.tests.test__walkdirs_win32',
2790
2801
                   'bzrlib.tests.test_weave',
2791
2802
                   'bzrlib.tests.test_whitebox',
2792
2803
                   'bzrlib.tests.test_win32utils',
2965
2976
 
2966
2977
def adapt_modules(mods_list, adapter, loader, suite):
2967
2978
    """Adapt the modules in mods_list using adapter and add to suite."""
2968
 
    for test in iter_suite_tests(loader.loadTestsFromModuleNames(mods_list)):
 
2979
    tests = loader.loadTestsFromModuleNames(mods_list)
 
2980
    adapt_tests(tests, adapter, suite)
 
2981
 
 
2982
 
 
2983
def adapt_tests(tests_list, adapter, suite):
 
2984
    """Adapt the tests in tests_list using adapter and add to suite."""
 
2985
    for test in iter_suite_tests(tests_list):
2969
2986
        suite.addTests(adapter.adapt(test))
2970
2987
 
2971
2988
 
2972
 
def adapt_tests(tests_list, adapter, loader, suite):
2973
 
    """Adapt the tests in tests_list using adapter and add to suite."""
2974
 
    for test in tests_list:
2975
 
        suite.addTests(adapter.adapt(loader.loadTestsFromName(test)))
2976
 
 
2977
 
 
2978
2989
def _rmtree_temp_dir(dirname):
2979
2990
    # If LANG=C we probably have created some bogus paths
2980
2991
    # which rmtree(unicode) will fail to delete
3059
3070
OsFifoFeature = _OsFifoFeature()
3060
3071
 
3061
3072
 
 
3073
class _UnicodeFilenameFeature(Feature):
 
3074
    """Does the filesystem support Unicode filenames?"""
 
3075
 
 
3076
    def _probe(self):
 
3077
        try:
 
3078
            # Check for character combinations unlikely to be covered by any
 
3079
            # single non-unicode encoding. We use the characters
 
3080
            # - greek small letter alpha (U+03B1) and
 
3081
            # - braille pattern dots-123456 (U+283F).
 
3082
            os.stat(u'\u03b1\u283f')
 
3083
        except UnicodeEncodeError:
 
3084
            return False
 
3085
        except (IOError, OSError):
 
3086
            # The filesystem allows the Unicode filename but the file doesn't
 
3087
            # exist.
 
3088
            return True
 
3089
        else:
 
3090
            # The filesystem allows the Unicode filename and the file exists,
 
3091
            # for some reason.
 
3092
            return True
 
3093
 
 
3094
UnicodeFilenameFeature = _UnicodeFilenameFeature()
 
3095
 
 
3096
 
3062
3097
class TestScenarioApplier(object):
3063
3098
    """A tool to apply scenarios to tests."""
3064
3099
 
3141
3176
FTPServerFeature = _FTPServerFeature()
3142
3177
 
3143
3178
 
 
3179
class _UnicodeFilename(Feature):
 
3180
    """Does the filesystem support Unicode filenames?"""
 
3181
 
 
3182
    def _probe(self):
 
3183
        try:
 
3184
            os.stat(u'\u03b1')
 
3185
        except UnicodeEncodeError:
 
3186
            return False
 
3187
        except (IOError, OSError):
 
3188
            # The filesystem allows the Unicode filename but the file doesn't
 
3189
            # exist.
 
3190
            return True
 
3191
        else:
 
3192
            # The filesystem allows the Unicode filename and the file exists,
 
3193
            # for some reason.
 
3194
            return True
 
3195
 
 
3196
UnicodeFilename = _UnicodeFilename()
 
3197
 
 
3198
 
 
3199
class _UTF8Filesystem(Feature):
 
3200
    """Is the filesystem UTF-8?"""
 
3201
 
 
3202
    def _probe(self):
 
3203
        if osutils._fs_enc.upper() in ('UTF-8', 'UTF8'):
 
3204
            return True
 
3205
        return False
 
3206
 
 
3207
UTF8Filesystem = _UTF8Filesystem()
 
3208
 
 
3209
 
3144
3210
class _CaseInsensitiveFilesystemFeature(Feature):
3145
3211
    """Check if underlined filesystem is case-insensitive
3146
3212
    (e.g. on Windows, Cygwin, MacOS)