/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 breezy/tests/features.py

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    def feature_name(self):
70
70
        return 'symlinks'
71
71
 
72
 
 
73
72
SymlinkFeature = _SymlinkFeature()
74
73
 
75
74
 
81
80
    def feature_name(self):
82
81
        return 'hardlinks'
83
82
 
84
 
 
85
83
HardlinkFeature = _HardlinkFeature()
86
84
 
87
85
 
93
91
    def feature_name(self):
94
92
        return 'filesystem fifos'
95
93
 
96
 
 
97
94
OsFifoFeature = _OsFifoFeature()
98
95
 
99
96
 
118
115
            # for some reason.
119
116
            return True
120
117
 
121
 
 
122
118
UnicodeFilenameFeature = _UnicodeFilenameFeature()
123
119
 
124
120
 
238
234
 
239
235
    def _probe(self):
240
236
        try:
241
 
            import ssl  # noqa: F401
 
237
            import ssl
242
238
            return True
243
239
        except ImportError:
244
240
            return False
258
254
            return True
259
255
        return False
260
256
 
261
 
 
262
257
ByteStringNamedFilesystem = _ByteStringNamedFilesystem()
263
258
 
264
259
 
270
265
            return True
271
266
        return False
272
267
 
273
 
 
274
268
UTF8Filesystem = _UTF8Filesystem()
275
269
 
276
270
 
286
280
            # We trigger SIGBREAK via a Console api so we need ctypes to
287
281
            # access the function
288
282
            try:
289
 
                import ctypes  # noqa: F401
 
283
                import ctypes
290
284
            except OSError:
291
285
                return False
292
286
        return True
309
303
            name = osutils.normpath(name)
310
304
            base, rel = osutils.split(name)
311
305
            found_rel = osutils.canonical_relpath(base, name)
312
 
            return (found_rel == rel and
313
 
                    os.path.isfile(name.upper()) and
314
 
                    os.path.isfile(name.lower()))
 
306
            return (found_rel == rel
 
307
                    and os.path.isfile(name.upper())
 
308
                    and os.path.isfile(name.lower()))
315
309
        finally:
316
310
            os.close(fileno)
317
311
            os.remove(name)
319
313
    def feature_name(self):
320
314
        return "case-insensitive case-preserving filesystem"
321
315
 
322
 
 
323
316
CaseInsCasePresFilenameFeature = _CaseInsCasePresFilenameFeature()
324
317
 
325
318
 
342
335
        else:
343
336
            root = tests.TestCaseWithMemoryTransport.TEST_ROOT
344
337
        tdir = osutils.mkdtemp(prefix='case-sensitive-probe-', suffix='',
345
 
                               dir=root)
 
338
            dir=root)
346
339
        name_a = osutils.pathjoin(tdir, 'a')
347
340
        name_A = osutils.pathjoin(tdir, 'A')
348
341
        os.mkdir(name_a)
353
346
    def feature_name(self):
354
347
        return 'case-insensitive filesystem'
355
348
 
356
 
 
357
349
CaseInsensitiveFilesystemFeature = _CaseInsensitiveFilesystemFeature()
358
350
 
359
351
 
370
362
    def feature_name(self):
371
363
        return 'case-sensitive filesystem'
372
364
 
373
 
 
374
365
# new coding style is for feature instances to be lowercase
375
366
case_sensitive_filesystem_feature = _CaseSensitiveFilesystemFeature()
376
367
 
402
393
pywintypes = ModuleAvailableFeature('pywintypes')
403
394
subunit = ModuleAvailableFeature('subunit')
404
395
testtools = ModuleAvailableFeature('testtools')
405
 
flake8 = ModuleAvailableFeature('flake8.api.legacy')
406
396
 
 
397
compiled_patiencediff_feature = ModuleAvailableFeature(
 
398
    'breezy._patiencediff_c')
407
399
lsprof_feature = ModuleAvailableFeature('breezy.lsprof')
408
 
pkg_resources_feature = ModuleAvailableFeature('pkg_resources')
409
400
 
410
401
 
411
402
class _BackslashDirSeparatorFeature(Feature):
421
412
    def feature_name(self):
422
413
        return "Filesystem treats '\\' as a directory separator."
423
414
 
424
 
 
425
415
backslashdir_feature = _BackslashDirSeparatorFeature()
426
416
 
427
417
 
431
421
    def _probe(self):
432
422
        return os.name == 'posix' and hasattr(os, 'chown')
433
423
 
434
 
 
435
424
chown_feature = _ChownFeature()
436
425
 
437
426
 
493
482
    def _probe(self):
494
483
        try:
495
484
            proc = subprocess.Popen(['strace'],
496
 
                                    stderr=subprocess.PIPE,
497
 
                                    stdout=subprocess.PIPE)
 
485
                stderr=subprocess.PIPE,
 
486
                stdout=subprocess.PIPE)
498
487
            proc.communicate()
499
488
            return True
500
489
        except OSError as e:
501
 
            import errno
502
490
            if e.errno == errno.ENOENT:
503
491
                # strace is not installed
504
492
                return False
519
507
            return False
520
508
        try:
521
509
            proc = subprocess.Popen(['attrib', '.'], stdout=subprocess.PIPE)
522
 
        except OSError:
 
510
        except OSError as e:
523
511
            return False
524
512
        return (0 == proc.wait())
525
513
 
568
556
BackslashFilenameFeature = _BackslashFilenameFeature()
569
557
 
570
558
 
571
 
class PathFeature(Feature):
572
 
    """Feature testing whether a particular path exists."""
573
 
 
574
 
    def __init__(self, path):
575
 
        super(PathFeature, self).__init__()
576
 
        self.path = path
 
559
class _ColorFeature(Feature):
577
560
 
578
561
    def _probe(self):
579
 
        return os.path.exists(self.path)
 
562
        from breezy._termcolor import allow_color
 
563
        return allow_color()
580
564
 
581
565
    def feature_name(self):
582
 
        return "%s exists" % self.path
 
566
        return "Terminal supports color."
 
567
 
 
568
ColorFeature = _ColorFeature()