[py-svn] r10418 - in py/branch/py-collect/test: . testing tkinter
hpk at codespeak.net
hpk at codespeak.net
Fri Apr 8 03:23:35 CEST 2005
Author: hpk
Date: Fri Apr 8 03:23:34 2005
New Revision: 10418
Modified:
py/branch/py-collect/test/cmdline.py
py/branch/py-collect/test/drive.py
py/branch/py-collect/test/run.py
py/branch/py-collect/test/testing/test_drive.py
py/branch/py-collect/test/tkinter/guidriver.py
py/branch/py-collect/test/tkinter/tkgui.py
Log:
first round of renaming some driver methods (i hope i
catched all tkinter references, can't test it on
my OSX yet).
But i even intend to do some more renamings, mainly: driver ->
session because while reading Jan Balster's new tkinter
frontend code i realized that 'TerminalSession' and
'GUISession' make more intuitive sense than "...Driver" ...
Modified: py/branch/py-collect/test/cmdline.py
==============================================================================
--- py/branch/py-collect/test/cmdline.py (original)
+++ py/branch/py-collect/test/cmdline.py Fri Apr 8 03:23:34 2005
@@ -8,7 +8,7 @@
args = py.std.sys.argv[1:]
driver, paths = py.test.config.init(args)
try:
- driver.runpaths(*paths)
+ driver.runsession(paths)
except KeyboardInterrupt:
print
print "Keybordinterrupt"
Modified: py/branch/py-collect/test/drive.py
==============================================================================
--- py/branch/py-collect/test/drive.py (original)
+++ py/branch/py-collect/test/drive.py Fri Apr 8 03:23:34 2005
@@ -36,19 +36,14 @@
def warning(self, msg):
raise Warning(msg)
- def runpaths(self, *paths):
- #print "runpaths", paths
- from py.__impl__.test.collect import getfscollector
- cols = [getfscollector(p) for p in paths]
- return self.run(cols)
-
- def run(self, colitems):
+ def runsession(self, *objs):
""" main loop for running tests. """
+ colitems = map2colitems(objs)
try:
self.header(colitems)
try:
for colitem in colitems:
- self.runone(colitem)
+ self.runtraced(colitem)
finally:
self.footer(colitems)
except Exit, ex:
@@ -59,19 +54,20 @@
for item, res in self.getresults(py.test.Item.Failed)]
- def runone(self, colitem):
+ def runtraced(self, colitem):
if self.shouldclose():
raise SystemExit, "received external close signal"
- capture = None
if not self.option.nocapture and isinstance(colitem, py.test.Item):
capture = SimpleOutErrCapture()
+ else:
+ capture = None
try:
self.start(colitem)
res = None
try:
try:
- res = self.runinner(colitem)
+ res = self.run(colitem)
except (KeyboardInterrupt, Exit):
raise
except colitem.Outcome, res:
@@ -93,7 +89,7 @@
except AttributeError:
pass
- def runinner(self, colitem):
+ def run(self, colitem):
if self.option.collectonly and isinstance(colitem, py.test.Item):
return
res = colitem.run()
@@ -105,10 +101,20 @@
"sequence nor None: %r" % (colitem, res))
return colitem.Passed()
for obj in seq:
- #print "diving into", obj
- self.runone(obj)
+ self.runtraced(obj)
return res
+def map2colitems(items):
+ # first convert all path objects into collectors
+ from py.__impl__.test.collect import getfscollector
+ colitems = []
+ for item in items:
+ if isinstance(item, (list, tuple)):
+ colitems.extend(map2colitems(item))
+ elif not isinstance(item, py.test.collect.Collector):
+ colitems.append(getfscollector(item))
+ return colitems
+
class Exit(Exception):
""" for immediate program exits without tracebacks and reporter/summary. """
def __init__(self, msg="unknown reason", item=None):
Modified: py/branch/py-collect/test/run.py
==============================================================================
--- py/branch/py-collect/test/run.py (original)
+++ py/branch/py-collect/test/run.py Fri Apr 8 03:23:34 2005
@@ -98,7 +98,7 @@
else:
cols = list(getcollectors(paths))
driver.shouldclose = channel.isclosed
- failures = driver.run(cols)
+ failures = driver.process(cols)
channel.send(failures)
class FailureCollector(py.test.collect.Collector):
Modified: py/branch/py-collect/test/testing/test_drive.py
==============================================================================
--- py/branch/py-collect/test/testing/test_drive.py (original)
+++ py/branch/py-collect/test/testing/test_drive.py Fri Apr 8 03:23:34 2005
@@ -7,7 +7,7 @@
class TestDefaultDriver:
def test_simple(self):
driver, paths = py.test.config.init([])
- driver.runpaths(datadir / 'filetest.py')
+ driver.runsession(datadir / 'filetest.py')
l = driver.getresults(py.test.Item.Failed)
assert len(l) == 2
l = driver.getresults(py.test.Item.Passed)
@@ -29,7 +29,7 @@
#f.flush()
def test_terminal(self):
- self.driver.runpaths(datadir / 'filetest.py')
+ self.driver.runsession(datadir / 'filetest.py')
out = self.file.getvalue()
#print "memo"
#print self.driver._memo
@@ -42,7 +42,7 @@
def test_exit_first_problem(self):
driver = self.driver
driver.option.exitfirstproblem = True
- driver.runpaths(str(datadir / 'filetest.py'))
+ driver.runsession(str(datadir / 'filetest.py'))
l = driver.getresults(py.test.Item.Failed)
assert len(l) == 1
l = driver.getresults(py.test.Item.Passed)
@@ -51,7 +51,7 @@
def test_collectonly(self):
driver = self.driver
driver.option.collectonly = True
- driver.runpaths(str(datadir / 'filetest.py'))
+ driver.runsession(str(datadir / 'filetest.py'))
out = self.file.getvalue()
#print out
l = driver.getresults(py.test.Item.Failed)
@@ -78,9 +78,9 @@
#print "hello"
driver = self.driver
#driver.option.nocapture = True
- print "calling runpaths", o
- driver.runpaths(str(o))
- print "back from runpaths", o
+ print "calling runsession", o
+ driver.runsession(str(o))
+ print "back from runsession", o
out = self.file.getvalue()
#print out
i = out.find('Recursion detected')
@@ -94,7 +94,7 @@
yield None
"""))
driver = self.driver
- driver.runpaths(o)
+ driver.runsession(o)
out = self.file.getvalue()
#print out
i = out.find('TypeError')
@@ -124,7 +124,7 @@
"""))
driver = self.driver
- driver.runpaths(o)
+ driver.runsession([o])
l = driver.getresults(py.test.Item.Failed)
assert len(l) == 0
l = driver.getresults(py.test.Item.Passed)
Modified: py/branch/py-collect/test/tkinter/guidriver.py
==============================================================================
--- py/branch/py-collect/test/tkinter/guidriver.py (original)
+++ py/branch/py-collect/test/tkinter/guidriver.py Fri Apr 8 03:23:34 2005
@@ -47,39 +47,3 @@
def warning(self, msg):
pass
- # hack! Driver.runone should be patched
- def runone(self, colitem):
- if self.shouldclose():
- raise SystemExit, "received external close signal"
-
- capture = None
- if not self.option.nocapture and isinstance(colitem, py.test.Item):
- capture = SimpleOutErrCapture()
- res = None
- try:
- self.start(colitem)
- try:
- try:
- res = self.runinner(colitem)
- except (KeyboardInterrupt, Exit):
- res = None
- raise
- except colitem.Outcome, res:
- res.excinfo = py.code.ExceptionInfo()
- except:
- excinfo = py.code.ExceptionInfo()
- res = colitem.Failed(excinfo=excinfo)
- else:
- assert (res is None or
- isinstance(res, (list, colitem.Outcome)))
- finally:
- if capture is not None:
- out, err = capture.reset()
- try:
- res.out, res.err = out, err
- except AttributeError:
- pass
- self.finish(colitem, res)
- finally:
- pass
-
Modified: py/branch/py-collect/test/tkinter/tkgui.py
==============================================================================
--- py/branch/py-collect/test/tkinter/tkgui.py (original)
+++ py/branch/py-collect/test/tkinter/tkgui.py Fri Apr 8 03:23:34 2005
@@ -335,7 +335,7 @@
# hack!!
frontenddriver, paths = py.test.config.init(args)
driver = GuiDriver(option = frontenddriver.option, channel = channel)
- driver.run(col)
+ driver.process(col)
""")
channel.send((rerun_cols, self.args))
self.receive_all_data(channel)
More information about the pytest-commit
mailing list