[Python-checkins] cpython (merge default -> default): Merge heads
kurt.kaiser
python-checkins at python.org
Fri Mar 25 05:33:12 CET 2011
http://hg.python.org/cpython/rev/82bbfd1cade2
changeset: 68913:82bbfd1cade2
parent: 68912:182bfffb2792
parent: 68905:6a649a15cd14
user: Kurt B. Kaiser <kbk at shore.net>
date: Thu Mar 24 15:10:28 2011 -0400
summary:
Merge heads
files:
Lib/test/test_future1.py | Bin
Lib/test/test_future2.py | Bin
Lib/test/regrtest.py | 29 +++++++++++++++++-----
Lib/test/test_collections.py | 25 -------------------
Lib/test/test_future.py | 12 ++++----
5 files changed, 28 insertions(+), 38 deletions(-)
diff --git a/Lib/test/test_future1.py b/Lib/test/future_test1.py
rename from Lib/test/test_future1.py
rename to Lib/test/future_test1.py
diff --git a/Lib/test/test_future2.py b/Lib/test/future_test2.py
rename from Lib/test/test_future2.py
rename to Lib/test/future_test2.py
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -42,6 +42,9 @@
-- specify which special resource intensive tests to run
-M/--memlimit LIMIT
-- run very large memory-consuming tests
+ --testdir DIR
+ -- execute test files in the specified directory (instead
+ of the Python stdlib test suite)
Special runs
@@ -265,7 +268,7 @@
'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir',
'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=',
'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug',
- 'start=', 'nowindows', 'header'])
+ 'start=', 'nowindows', 'header', 'testdir='])
except getopt.error as msg:
usage(msg)
@@ -315,7 +318,9 @@
elif o in ('-T', '--coverage'):
trace = True
elif o in ('-D', '--coverdir'):
- coverdir = os.path.join(os.getcwd(), a)
+ # CWD is replaced with a temporary dir before calling main(), so we
+ # need join it with the saved CWD so it goes where the user expects.
+ coverdir = os.path.join(support.SAVEDCWD, a)
elif o in ('-N', '--nocoverdir'):
coverdir = None
elif o in ('-R', '--huntrleaks'):
@@ -393,6 +398,10 @@
print() # Force a newline (just in case)
print(json.dumps(result))
sys.exit(0)
+ elif o == '--testdir':
+ # CWD is replaced with a temporary dir before calling main(), so we
+ # join it with the saved CWD so it ends up where the user expects.
+ testdir = os.path.join(support.SAVEDCWD, a)
else:
print(("No handler for option {}. Please report this as a bug "
"at http://bugs.python.org.").format(o), file=sys.stderr)
@@ -467,7 +476,13 @@
print("== ", os.getcwd())
print("Testing with flags:", sys.flags)
- alltests = findtests(testdir, stdtests, nottests)
+ # if testdir is set, then we are not running the python tests suite, so
+ # don't add default tests to be executed or skipped (pass empty values)
+ if testdir:
+ alltests = findtests(testdir, list(), set())
+ else:
+ alltests = findtests(testdir, stdtests, nottests)
+
selected = tests or args or alltests
if single:
selected = selected[:1]
@@ -713,6 +728,8 @@
sys.exit(len(bad) > 0 or interrupted)
+# small set of tests to determine if we have a basically functioning interpreter
+# (i.e. if any of these fail, then anything else is likely to follow)
STDTESTS = [
'test_grammar',
'test_opcodes',
@@ -725,10 +742,8 @@
'test_doctest2',
]
-NOTTESTS = {
- 'test_future1',
- 'test_future2',
-}
+# set of tests that we don't want to be executed when using regrtest
+NOTTESTS = set()
def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
"""Return a list of all applicable test modules."""
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -332,37 +332,12 @@
# verify that _source can be run through exec()
tmp = namedtuple('NTColor', 'red green blue')
globals().pop('NTColor', None) # remove artifacts from other tests
- self.assertNotIn('NTColor', globals())
exec(tmp._source, globals())
self.assertIn('NTColor', globals())
c = NTColor(10, 20, 30)
self.assertEqual((c.red, c.green, c.blue), (10, 20, 30))
self.assertEqual(NTColor._fields, ('red', 'green', 'blue'))
globals().pop('NTColor', None) # clean-up after this test
- self.assertNotIn('NTColor', globals())
-
- def test_source_importable(self):
- tmp = namedtuple('Color', 'hue sat val')
-
- compiled = None
- source = TESTFN + '.py'
- with open(source, 'w') as f:
- print(tmp._source, file=f)
-
- if TESTFN in sys.modules:
- del sys.modules[TESTFN]
- try:
- mod = __import__(TESTFN)
- compiled = mod.__file__
- Color = mod.Color
- c = Color(10, 20, 30)
- self.assertEqual((c.hue, c.sat, c.val), (10, 20, 30))
- self.assertEqual(Color._fields, ('hue', 'sat', 'val'))
- finally:
- forget(TESTFN)
- if compiled:
- unlink(compiled)
- unlink(source)
################################################################################
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py
--- a/Lib/test/test_future.py
+++ b/Lib/test/test_future.py
@@ -13,14 +13,14 @@
class FutureTest(unittest.TestCase):
def test_future1(self):
- support.unload('test_future1')
- from test import test_future1
- self.assertEqual(test_future1.result, 6)
+ support.unload('future_test1')
+ from test import future_test1
+ self.assertEqual(future_test1.result, 6)
def test_future2(self):
- support.unload('test_future2')
- from test import test_future2
- self.assertEqual(test_future2.result, 6)
+ support.unload('future_test2')
+ from test import future_test2
+ self.assertEqual(future_test2.result, 6)
def test_future3(self):
support.unload('test_future3')
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list