791
792
This is used to exercise the test framework.
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')
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'}\)")
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'}\)")
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")
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'>"
1923
self.assertEqual(str(e),
1924
"None is an instance of <class 'NoneType'> rather than <class 'int'>: it's "
1927
self.assertEqual(str(e),
1928
"None is an instance of <type 'NoneType'> rather than <type 'int'>"
1919
1931
def test_assertEndsWith(self):
1920
1932
self.assertEndsWith('foo', 'oo')
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')
2868
2880
class TestTestLoader(tests.TestCase):