~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

terminal_width can now returns None.

* bzrlib/win32utils.py:
(get_console_size): Fix typo in comment.

* bzrlib/ui/text.py:
(TextProgressView._show_line): Handle the no terminal present case.

* bzrlib/tests/test_osutils.py:
(TestTerminalWidth): Update tests.

* bzrlib/tests/blackbox/test_too_much.py:
Fix some imports.
(OldTests.test_bzr): Handle the no terminal present case.

* bzrlib/tests/__init__.py:
(VerboseTestResult.report_test_start): Handle the no terminal
present case.

* bzrlib/status.py:
(show_pending_merges): Handle the no terminal present case.
(show_pending_merges.show_log_message): Factor out some
code. Handle the no terminal present case.

* bzrlib/osutils.py:
(terminal_width): Return None if no precise value can be found.

* bzrlib/log.py:
(LineLogFormatter.__init__): Handle the no terminal present case.
(LineLogFormatter.truncate): Accept None as max_len meaning no
truncation.
(LineLogFormatter.log_string): 

* bzrlib/help.py:
(_help_commands_to_text): Handle the no terminal present case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    multiparent,
29
29
    osutils,
30
30
    pack,
31
 
    tests,
32
31
    )
33
32
from bzrlib.errors import (
34
33
    RevisionAlreadyPresent,
70
69
    )
71
70
 
72
71
 
73
 
compiled_knit_feature = tests.ModuleAvailableFeature(
74
 
                            'bzrlib._knit_load_data_pyx')
 
72
class _CompiledKnitFeature(Feature):
 
73
 
 
74
    def _probe(self):
 
75
        try:
 
76
            import bzrlib._knit_load_data_pyx
 
77
        except ImportError:
 
78
            return False
 
79
        return True
 
80
 
 
81
    def feature_name(self):
 
82
        return 'bzrlib._knit_load_data_pyx'
 
83
 
 
84
CompiledKnitFeature = _CompiledKnitFeature()
75
85
 
76
86
 
77
87
class KnitContentTestsMixin(object):
862
872
 
863
873
    def get_knit_index(self, transport, name, mode):
864
874
        mapper = ConstantMapper(name)
 
875
        orig = knit._load_data
 
876
        def reset():
 
877
            knit._load_data = orig
 
878
        self.addCleanup(reset)
865
879
        from bzrlib._knit_load_data_py import _load_data_py
866
 
        self.overrideAttr(knit, '_load_data', _load_data_py)
 
880
        knit._load_data = _load_data_py
867
881
        allow_writes = lambda: 'w' in mode
868
882
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
869
883
 
1294
1308
 
1295
1309
class LowLevelKnitIndexTests_c(LowLevelKnitIndexTests):
1296
1310
 
1297
 
    _test_needs_features = [compiled_knit_feature]
 
1311
    _test_needs_features = [CompiledKnitFeature]
1298
1312
 
1299
1313
    def get_knit_index(self, transport, name, mode):
1300
1314
        mapper = ConstantMapper(name)
 
1315
        orig = knit._load_data
 
1316
        def reset():
 
1317
            knit._load_data = orig
 
1318
        self.addCleanup(reset)
1301
1319
        from bzrlib._knit_load_data_pyx import _load_data_c
1302
 
        self.overrideAttr(knit, '_load_data', _load_data_c)
 
1320
        knit._load_data = _load_data_c
1303
1321
        allow_writes = lambda: mode == 'w'
1304
 
        return _KndxIndex(transport, mapper, lambda:None,
1305
 
                          allow_writes, lambda:True)
 
1322
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
1306
1323
 
1307
1324
 
1308
1325
class Test_KnitAnnotator(TestCaseWithMemoryTransport):