Lines Matching defs:Test
13 from test import support
17 from unittest.test.support import (
21 from test.support import captured_stderr
29 class Test(object):
40 """A test case which logs its calls."""
43 super(Test.LoggingTestCase, self).__init__('test')
49 def test(self):
50 self.events.append('test')
62 eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))]
65 ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest')),
66 (Test.Foo('test1'), Test.Bar('test1')),
67 (Test.Foo('test1'), Test.Bar('test2'))]
75 # "Each instance of TestCase will run a single test method: the
83 class Test(unittest.TestCase):
85 def test(self): pass
87 self.assertEqual(Test().id()[-13:], '.Test.runTest')
89 # test that TestCase can be instantiated with no args
91 test = unittest.TestCase()
92 test.assertEqual(3, 3)
93 with test.assertRaises(test.failureException):
94 test.assertEqual(3, 2)
97 test.run()
101 # "Each instance of TestCase will run a single test method: the
104 class Test(unittest.TestCase):
106 def test(self): pass
108 self.assertEqual(Test('test').id()[-10:], '.Test.test')
112 # "Each instance of TestCase will run a single test method: the
115 class Test(unittest.TestCase):
117 def test(self): pass
120 Test('testfoo')
126 # "Return the number of tests represented by the this test object. For
130 def test(self): pass
132 self.assertEqual(Foo('test').countTestCases(), 1)
134 # "Return the default type of test result object to be used to run this
135 # test. For TestCase instances, this will always be
146 # "When a setUp() method is defined, the test runner will run that method
147 # prior to each test. Likewise, if a tearDown() method is defined, the
148 # test runner will invoke that method after each test. In the example,
149 # setUp() was used to create a fresh sequence for each test."
157 class Foo(Test.LoggingTestCase):
170 class Foo(Test.LoggingTestCase):
183 # "When a setUp() method is defined, the test runner will run that method
184 # prior to each test. Likewise, if a tearDown() method is defined, the
185 # test runner will invoke that method after each test. In the example,
186 # setUp() was used to create a fresh sequence for each test."
188 # Make sure the proper call order is maintained, even if the test raises
194 class Foo(Test.LoggingTestCase):
195 def test(self):
196 super(Foo, self).test()
197 raise RuntimeError('raised by Foo.test')
199 expected = ['startTest', 'setUp', 'test', 'tearDown',
204 # "With a default result, an error in the test still results in stopTestRun
209 class Foo(Test.LoggingTestCase):
213 def test(self):
214 super(Foo, self).test()
215 raise RuntimeError('raised by Foo.test')
217 expected = ['startTestRun', 'startTest', 'setUp', 'test',
222 # "When a setUp() method is defined, the test runner will run that method
223 # prior to each test. Likewise, if a tearDown() method is defined, the
224 # test runner will invoke that method after each test. In the example,
225 # setUp() was used to create a fresh sequence for each test."
227 # Make sure the proper call order is maintained, even if the test signals
233 class Foo(Test.LoggingTestCase):
234 def test(self):
235 super(Foo, self).test()
236 self.fail('raised by Foo.test')
238 expected = ['startTest', 'setUp', 'test', 'tearDown',
243 # "When a test fails with a default result stopTestRun is still called."
246 class Foo(Test.LoggingTestCase):
249 def test(self):
250 super(Foo, self).test()
251 self.fail('raised by Foo.test')
253 expected = ['startTestRun', 'startTest', 'setUp', 'test',
259 # "When a setUp() method is defined, the test runner will run that method
260 # prior to each test. Likewise, if a tearDown() method is defined, the
261 # test runner will invoke that method after each test. In the example,
262 # setUp() was used to create a fresh sequence for each test."
270 class Foo(Test.LoggingTestCase):
276 expected = ['startTest', 'setUp', 'test', 'tearDown', 'addError',
283 class Foo(Test.LoggingTestCase):
292 expected = ['startTestRun', 'startTest', 'setUp', 'test', 'tearDown',
303 def test(self):
306 Foo('test').run()
309 class Foo(Test.LoggingTestCase):
310 def test(self):
311 super(Foo, self).test()
319 raise RuntimeError('raised by Foo.test')
335 expected = ['startTest', 'setUp', 'test', 'tearDown',
346 expected = ['startTest', 'setUp', 'test', 'tearDown',
351 class Foo(Test.LoggingTestCase):
352 def test(self):
353 super(Foo, self).test()
367 # to the whole test success.
368 expected = (['startTest', 'setUp', 'test', 'tearDown']
374 # With a legacy result, only the whole test success is recorded.
377 expected = ['startTest', 'setUp', 'test', 'tearDown',
386 class Foo(Test.LoggingTestCase):
387 def test(self):
388 super(Foo, self).test()
395 expected = ['startTest', 'setUp', 'test', 'tearDown',
401 # Ensure proper test flow with subtests and failfast (issue #22894)
429 # Test debug() with a test that uses subTest() (bpo-34900)
434 events.append('test case')
440 self.assertEqual(events, ['test case', 'subtest 1'])
442 # "This class attribute gives the exception raised by the test() method.
443 # If a test framework needs to use a specialized exception, possibly to
449 def test(self):
452 self.assertIs(Foo('test').failureException, AssertionError)
454 # "This class attribute gives the exception raised by the test() method.
455 # If a test framework needs to use a specialized exception, possibly to
465 def test(self):
470 self.assertIs(Foo('test').failureException, RuntimeError)
473 Foo('test').run(result)
477 # "This class attribute gives the exception raised by the test() method.
478 # If a test framework needs to use a specialized exception, possibly to
488 def test(self):
493 self.assertIs(Foo('test').failureException, RuntimeError)
496 Foo('test').run(result)
518 # "Return a string identifying the specific test case."
521 # test down too much. Really all that can be asserted is that the id()
541 def test(self):
542 events.append('test')
548 result = Foo('test').run()
551 expected = ['startTestRun', 'startTest', 'test', 'addSuccess',
560 def test(self):
565 retval = Foo('test').run(result)
576 def test(self):
583 retval = Foo('test')(resultIn)
707 # This mess of try excepts is to test the assertEqual behavior
843 test = unittest.TestCase('assertEqual')
846 test._truncateMessage = truncate
848 test.assertDictEqual({}, {1: 0})
855 test = unittest.TestCase('assertEqual')
858 test._truncateMessage = truncate
860 test.assertMultiLineEqual('foo', 'bar')
948 # Test that sequences of unhashable objects can be tested for sameness:
950 # Test that iterator of unhashable objects can be tested for sameness:
980 # test utility functions supporting assertCountEqual()
1094 test case
1095 A test case is the smallest unit of testing. [...]
1099 test case
1100 A test case is the smallest unit of testing. [...] You may provide your
1108 test case
1109 - A test case is the smallest unit of testing. [...]
1110 + A test case is the smallest unit of testing. [...] You may provide your
1666 Test that the deprecated methods raise a DeprecationWarning. See #9424.
1689 # disable this test for now. When the version where the fail* methods will
1692 """Test that the deprecated fail* methods get removed in 3.x"""
1710 test = TestableTest('testNothing')
1713 deepcopy(test)
1718 # Can't use TestCase classes defined in Test class as
1720 test = unittest.TestCase('run')
1724 pickled_test = pickle.dumps(test, protocol=protocol)
1726 self.assertEqual(test, unpickled_test)