/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/test_selftest.py

  • Committer: Jelmer Vernooij
  • Date: 2018-08-08 02:14:32 UTC
  • mfrom: (7063 work)
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180808021432-nomib3je4cu2xqkm
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import gc
20
20
import doctest
 
21
from functools import reduce
21
22
import os
22
23
import signal
23
24
import sys
790
791
 
791
792
        This is used to exercise the test framework.
792
793
        """
793
 
        self.time(text_type, 'hello', errors='replace')
794
 
        self.time(text_type, 'world', errors='replace')
 
794
        self.time(text_type, b'hello', errors='replace')
 
795
        self.time(text_type, b'world', errors='replace')
795
796
 
796
797
    def test_lsprofiling(self):
797
798
        """Verbose test result prints lsprof statistics from test cases."""
821
822
        # and then repeated but with 'world', rather than 'hello'.
822
823
        # this should appear in the output stream of our test result.
823
824
        output = result_stream.getvalue()
824
 
        self.assertContainsRe(output,
825
 
            r"LSProf output for <type 'unicode'>\(\('hello',\), {'errors': 'replace'}\)")
 
825
        if PY3:
 
826
            self.assertContainsRe(output,
 
827
                r"LSProf output for <class 'str'>\(\(b'hello',\), {'errors': 'replace'}\)")
 
828
            self.assertContainsRe(output,
 
829
                r"LSProf output for <class 'str'>\(\(b'world',\), {'errors': 'replace'}\)")
 
830
        else:
 
831
            self.assertContainsRe(output,
 
832
                r"LSProf output for <type 'unicode'>\(\('hello',\), {'errors': 'replace'}\)")
 
833
            self.assertContainsRe(output,
 
834
                r"LSProf output for <type 'unicode'>\(\('world',\), {'errors': 'replace'}\)\n")
826
835
        self.assertContainsRe(output,
827
836
            r" *CallCount *Recursive *Total\(ms\) *Inline\(ms\) *module:lineno\(function\)\n")
828
837
        self.assertContainsRe(output,
829
838
            r"( +1 +0 +0\.\d+ +0\.\d+ +<method 'disable' of '_lsprof\.Profiler' objects>\n)?")
830
 
        self.assertContainsRe(output,
831
 
            r"LSProf output for <type 'unicode'>\(\('world',\), {'errors': 'replace'}\)\n")
832
839
 
833
840
    def test_uses_time_from_testtools(self):
834
841
        """Test case timings in verbose results should use testtools times"""
1912
1919
        self.assertRaises(AssertionError, self.assertIsInstance, 23.3, int)
1913
1920
        e = self.assertRaises(AssertionError,
1914
1921
            self.assertIsInstance, None, int, "it's just not")
1915
 
        self.assertEqual(str(e),
1916
 
            "None is an instance of <type 'NoneType'> rather than <type 'int'>"
1917
 
            ": it's just not")
 
1922
        if PY3:
 
1923
            self.assertEqual(str(e),
 
1924
                "None is an instance of <class 'NoneType'> rather than <class 'int'>: it's "
 
1925
                "just not")
 
1926
        else:
 
1927
            self.assertEqual(str(e),
 
1928
                "None is an instance of <type 'NoneType'> rather than <type 'int'>"
 
1929
                ": it's just not")
1918
1930
 
1919
1931
    def test_assertEndsWith(self):
1920
1932
        self.assertEndsWith('foo', 'oo')
2174
2186
 
2175
2187
    def test_load_list(self):
2176
2188
        # Provide a list with one test - this test.
2177
 
        test_id_line = b'%s\n' % self.id()
 
2189
        test_id_line = '%s\n' % self.id()
2178
2190
        self.build_tree_contents([('test.list', test_id_line)])
2179
2191
        # And generate a list of the tests in  the suite.
2180
2192
        stream = self.run_selftest(load_list='test.list', list_only=True)
2862
2874
        out, err = self.run_bzr(["log", "%s/nonexistantpath" % url], retcode=3)
2863
2875
        self.assertEqual(out, '')
2864
2876
        self.assertContainsRe(err,
2865
 
            b'brz: ERROR: Not a branch: ".*nonexistantpath/".\n')
 
2877
            'brz: ERROR: Not a branch: ".*nonexistantpath/".\n')
2866
2878
 
2867
2879
 
2868
2880
class TestTestLoader(tests.TestCase):