mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	make class skipping decorators the same as skipping every test of the class
This removes ClassTestSuite and a good bit of hacks.
This commit is contained in:
		
							parent
							
								
									a7724e59e0
								
							
						
					
					
						commit
						176a56c69b
					
				
					 4 changed files with 26 additions and 64 deletions
				
			
		|  | @ -107,7 +107,7 @@ def test_hash(self): | |||
| # List subclass we can add attributes to. | ||||
| class MyClassSuite(list): | ||||
| 
 | ||||
|     def __init__(self, tests, klass): | ||||
|     def __init__(self, tests): | ||||
|         super(MyClassSuite, self).__init__(tests) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -1262,7 +1262,7 @@ def foo_bar(self): pass | |||
|         tests = [Foo('test_1'), Foo('test_2')] | ||||
| 
 | ||||
|         loader = unittest.TestLoader() | ||||
|         loader.classSuiteClass = MyClassSuite | ||||
|         loader.suiteClass = list | ||||
|         self.assertEqual(loader.loadTestsFromTestCase(Foo), tests) | ||||
| 
 | ||||
|     # It is implicit in the documentation for TestLoader.suiteClass that | ||||
|  | @ -1275,7 +1275,7 @@ def test_2(self): pass | |||
|             def foo_bar(self): pass | ||||
|         m.Foo = Foo | ||||
| 
 | ||||
|         tests = [unittest.ClassTestSuite([Foo('test_1'), Foo('test_2')], Foo)] | ||||
|         tests = [[Foo('test_1'), Foo('test_2')]] | ||||
| 
 | ||||
|         loader = unittest.TestLoader() | ||||
|         loader.suiteClass = list | ||||
|  | @ -1294,7 +1294,7 @@ def foo_bar(self): pass | |||
|         tests = [Foo('test_1'), Foo('test_2')] | ||||
| 
 | ||||
|         loader = unittest.TestLoader() | ||||
|         loader.classSuiteClass = MyClassSuite | ||||
|         loader.suiteClass = list | ||||
|         self.assertEqual(loader.loadTestsFromName('Foo', m), tests) | ||||
| 
 | ||||
|     # It is implicit in the documentation for TestLoader.suiteClass that | ||||
|  | @ -1307,7 +1307,7 @@ def test_2(self): pass | |||
|             def foo_bar(self): pass | ||||
|         m.Foo = Foo | ||||
| 
 | ||||
|         tests = [unittest.ClassTestSuite([Foo('test_1'), Foo('test_2')], Foo)] | ||||
|         tests = [[Foo('test_1'), Foo('test_2')]] | ||||
| 
 | ||||
|         loader = unittest.TestLoader() | ||||
|         loader.suiteClass = list | ||||
|  | @ -2871,7 +2871,7 @@ def test_skip(self): pass | |||
|                 def test_dont_skip(self): pass | ||||
|             test_do_skip = Foo("test_skip") | ||||
|             test_dont_skip = Foo("test_dont_skip") | ||||
|             suite = unittest.ClassTestSuite([test_do_skip, test_dont_skip], Foo) | ||||
|             suite = unittest.TestSuite([test_do_skip, test_dont_skip]) | ||||
|             events = [] | ||||
|             result = LoggingResult(events) | ||||
|             suite.run(result) | ||||
|  | @ -2890,9 +2890,10 @@ def test_1(self): | |||
|                 record.append(1) | ||||
|         record = [] | ||||
|         result = unittest.TestResult() | ||||
|         suite = unittest.ClassTestSuite([Foo("test_1")], Foo) | ||||
|         test = Foo("test_1") | ||||
|         suite = unittest.TestSuite([test]) | ||||
|         suite.run(result) | ||||
|         self.assertEqual(result.skipped, [(suite, "testing")]) | ||||
|         self.assertEqual(result.skipped, [(test, "testing")]) | ||||
|         self.assertEqual(record, []) | ||||
| 
 | ||||
|     def test_expected_failure(self): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson