mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	Fix details in the test:
- traceback should go to stdout! - don't import ni, import t1! - nicer support for command line options, only if run as __main__
This commit is contained in:
		
							parent
							
								
									16221126d6
								
							
						
					
					
						commit
						10887a3067
					
				
					 1 changed files with 13 additions and 3 deletions
				
			
		| 
						 | 
					@ -4,7 +4,6 @@ import sys, os, string, tempfile, traceback
 | 
				
			||||||
from os import mkdir, rmdir		# Can't test if these fail
 | 
					from os import mkdir, rmdir		# Can't test if these fail
 | 
				
			||||||
del mkdir, rmdir
 | 
					del mkdir, rmdir
 | 
				
			||||||
from test_support import verbose
 | 
					from test_support import verbose
 | 
				
			||||||
if sys.argv[1:2] == ['-q']: verbose = 0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Helpers to create and destroy hierarchies.
 | 
					# Helpers to create and destroy hierarchies.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +58,7 @@ def runtest(hier, code):
 | 
				
			||||||
	try:
 | 
						try:
 | 
				
			||||||
	    execfile(codefile, globals(), {})
 | 
						    execfile(codefile, globals(), {})
 | 
				
			||||||
	except:
 | 
						except:
 | 
				
			||||||
	    traceback.print_exc()
 | 
						    traceback.print_exc(file=sys.stdout)
 | 
				
			||||||
    finally:
 | 
					    finally:
 | 
				
			||||||
	sys.path[:] = savepath
 | 
						sys.path[:] = savepath
 | 
				
			||||||
	try:
 | 
						try:
 | 
				
			||||||
| 
						 | 
					@ -71,7 +70,7 @@ def runtest(hier, code):
 | 
				
			||||||
# Test descriptions
 | 
					# Test descriptions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
tests = [
 | 
					tests = [
 | 
				
			||||||
    ("t1", [("t1", None)], "import ni"),
 | 
					    ("t1", [("t1", None)], "import t1"),
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    ("t2", [
 | 
					    ("t2", [
 | 
				
			||||||
    ("t2", None),
 | 
					    ("t2", None),
 | 
				
			||||||
| 
						 | 
					@ -140,6 +139,7 @@ print "t4.sub.subsub.spam =", spam
 | 
				
			||||||
     "print __name__, 'loading'; import string; print string.spam"),
 | 
					     "print __name__, 'loading'; import string; print string.spam"),
 | 
				
			||||||
     ],
 | 
					     ],
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					import t5
 | 
				
			||||||
from t5 import *
 | 
					from t5 import *
 | 
				
			||||||
print dir()
 | 
					print dir()
 | 
				
			||||||
import t5
 | 
					import t5
 | 
				
			||||||
| 
						 | 
					@ -181,6 +181,16 @@ from package import * (defined in __init__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Run the tests
 | 
					# Run the tests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					args = []
 | 
				
			||||||
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					    args = sys.argv[1:]
 | 
				
			||||||
 | 
					    if args and args[0] == '-q':
 | 
				
			||||||
 | 
						verbose = 0
 | 
				
			||||||
 | 
						del args[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
for name, hier, code in tests:
 | 
					for name, hier, code in tests:
 | 
				
			||||||
 | 
					    if args and name not in args:
 | 
				
			||||||
 | 
						print "skipping test", name
 | 
				
			||||||
 | 
						continue
 | 
				
			||||||
    print "running test", name
 | 
					    print "running test", name
 | 
				
			||||||
    runtest(hier, code)
 | 
					    runtest(hier, code)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue