mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Make test_datetime a better citizen (issue #22540)
This commit is contained in:
		
							parent
							
								
									72b8a80e59
								
							
						
					
					
						commit
						392f4139b3
					
				
					 2 changed files with 6 additions and 6 deletions
				
			
		|  | @ -3,6 +3,7 @@ | ||||||
| See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases | See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
|  | import decimal | ||||||
| import sys | import sys | ||||||
| import pickle | import pickle | ||||||
| import random | import random | ||||||
|  | @ -3808,7 +3809,6 @@ def test_extra_attributes(self): | ||||||
|                 x.abc = 1 |                 x.abc = 1 | ||||||
| 
 | 
 | ||||||
|     def test_check_arg_types(self): |     def test_check_arg_types(self): | ||||||
|         import decimal |  | ||||||
|         class Number: |         class Number: | ||||||
|             def __init__(self, value): |             def __init__(self, value): | ||||||
|                 self.value = value |                 self.value = value | ||||||
|  |  | ||||||
|  | @ -1,20 +1,20 @@ | ||||||
| import unittest | import unittest | ||||||
| import sys | import sys | ||||||
|  | 
 | ||||||
| from test.support import import_fresh_module, run_unittest | from test.support import import_fresh_module, run_unittest | ||||||
| 
 | 
 | ||||||
| TESTS = 'test.datetimetester' | TESTS = 'test.datetimetester' | ||||||
| 
 | 
 | ||||||
| # XXX: import_fresh_module() is supposed to leave sys.module cache untouched, |  | ||||||
| # XXX: but it does not, so we have to save and restore it ourselves. |  | ||||||
| save_sys_modules = sys.modules.copy() |  | ||||||
| try: | try: | ||||||
|     pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'], |     pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'], | ||||||
|                                      blocked=['_datetime']) |                                      blocked=['_datetime']) | ||||||
|     fast_tests = import_fresh_module(TESTS, fresh=['datetime', |     fast_tests = import_fresh_module(TESTS, fresh=['datetime', | ||||||
|                                                    '_datetime', '_strptime']) |                                                    '_datetime', '_strptime']) | ||||||
| finally: | finally: | ||||||
|     sys.modules.clear() |     # XXX: import_fresh_module() is supposed to leave sys.module cache untouched, | ||||||
|     sys.modules.update(save_sys_modules) |     # XXX: but it does not, so we have to cleanup ourselves. | ||||||
|  |     for modname in ['datetime', '_datetime', '_strptime']: | ||||||
|  |         sys.modules.pop(modname, None) | ||||||
| test_modules = [pure_tests, fast_tests] | test_modules = [pure_tests, fast_tests] | ||||||
| test_suffixes = ["_Pure", "_Fast"] | test_suffixes = ["_Pure", "_Fast"] | ||||||
| # XXX(gb) First run all the _Pure tests, then all the _Fast tests.  You might | # XXX(gb) First run all the _Pure tests, then all the _Fast tests.  You might | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Antoine Pitrou
						Antoine Pitrou