1120
1120
self.assertTrue(result.wasSuccessful())
1122
1122
def test_skipped_from_setup(self):
1123
1124
class SkippedSetupTest(TestCase):
1125
1126
def setUp(self):
1127
calls.append('setUp')
1127
1128
self.addCleanup(self.cleanup)
1128
1129
raise TestSkipped('skipped setup')
1131
1132
self.fail('test reached')
1133
1134
def cleanup(self):
1135
calls.append('cleanup')
1136
1137
runner = TextTestRunner(stream=self._log_file)
1137
1138
test = SkippedSetupTest('test_skip')
1138
1139
result = self.run_test_runner(runner, test)
1139
1140
self.assertTrue(result.wasSuccessful())
1140
1141
# Check if cleanup was called the right number of times.
1141
self.assertEqual(0, test.counter)
1142
self.assertEqual(['setUp', 'cleanup'], calls)
1143
1144
def test_skipped_from_test(self):
1144
1146
class SkippedTest(TestCase):
1146
1148
def setUp(self):
1149
calls.append('setUp')
1148
1150
self.addCleanup(self.cleanup)
1150
1152
def test_skip(self):
1151
1153
raise TestSkipped('skipped test')
1153
1155
def cleanup(self):
1156
calls.append('cleanup')
1156
1158
runner = TextTestRunner(stream=self._log_file)
1157
1159
test = SkippedTest('test_skip')
1158
1160
result = self.run_test_runner(runner, test)
1159
1161
self.assertTrue(result.wasSuccessful())
1160
1162
# Check if cleanup was called the right number of times.
1161
self.assertEqual(0, test.counter)
1163
self.assertEqual(['setUp', 'cleanup'], calls)
1163
1165
def test_not_applicable(self):
1164
1166
# run a test that is skipped because it's not applicable