[py-svn] r7106 - in py/dist/py: . bin test
hpk at codespeak.net
hpk at codespeak.net
Sat Oct 23 17:26:09 CEST 2004
Author: hpk
Date: Sat Oct 23 17:26:08 2004
New Revision: 7106
Modified:
py/dist/py/bin/py.test
py/dist/py/pytest.py
py/dist/py/test/cmdline.py
py/dist/py/test/defaultconfig.py
py/dist/py/test/run.py
Log:
small refactoring and internal renaming ...
Modified: py/dist/py/bin/py.test
==============================================================================
--- py/dist/py/bin/py.test (original)
+++ py/dist/py/bin/py.test Sat Oct 23 17:26:08 2004
@@ -2,4 +2,4 @@
from _findpy import py
from py.__impl__.test.cmdline import main
-main(py.std.sys.argv)
+main()
Modified: py/dist/py/pytest.py
==============================================================================
--- py/dist/py/pytest.py (original)
+++ py/dist/py/pytest.py Sat Oct 23 17:26:08 2004
@@ -6,6 +6,9 @@
# mod = extpy.resolve()
# mod.module = 23
# directory = pypath.root.dirpath()
+
+import py
+pkgdir = py.magic.autopath().pkgdir
# default values for options (modified from cmdline)
verbose = 0
Modified: py/dist/py/test/cmdline.py
==============================================================================
--- py/dist/py/test/cmdline.py (original)
+++ py/dist/py/test/cmdline.py Sat Oct 23 17:26:08 2004
@@ -6,9 +6,7 @@
#
configbasename = 'pytest.py'
-def main(argv=None):
- # the collectors we will be running
- collectors = []
+def old(argv):
if argv is None:
argv = py.std.sys.argv
frame = py.std.sys._getframe(1)
@@ -16,31 +14,30 @@
if name != '__main__':
return # called from an imported test file
import __main__
- collectors.append(py.test.collect.Module(py.std.sys.argv[0]))
-
- args = argv[1:]
+ return [py.test.collect.Module(py.std.sys.argv[0])]
+
+def main():
+ args = py.std.sys.argv[1:]
py.test.config.readconfiguration(*getanchors(args))
-
if py.test.config.restartpython():
return
+
filenames = py.test.config.parseargs(args)
- collectors.extend(getcollectors(filenames))
- if not collectors:
- collectors.append(py.test.collect.Directory(py.path.local()))
+ collectors = getcollectors(filenames)
reporter = py.test.config.getfirst('getreporter') ()
- runner = py.test.Driver(reporter)
- runner.setup()
+ driver = py.test.Driver(reporter)
+ driver.setup()
try:
try:
reporter.start()
try:
for collector in collectors:
- runner.run(collector)
- except runner.Exit:
+ driver.run_collector_or_item(collector)
+ except driver.Exit:
pass
finally:
- runner.teardown()
+ driver.teardown()
except KeyboardInterrupt:
print >>py.std.sys.stderr, "KEYBOARD INTERRUPT"
py.std.sys.exit(2)
@@ -61,6 +58,8 @@
else:
raise RuntimeError, "%r does not exist" % fn
yielded = True
+ if not yielded:
+ yield py.test.collect.Directory(py.path.local())
def getanchors(args):
""" yield anchors from skimming the args for existing files/dirs. """
Modified: py/dist/py/test/defaultconfig.py
==============================================================================
--- py/dist/py/test/defaultconfig.py (original)
+++ py/dist/py/test/defaultconfig.py Sat Oct 23 17:26:08 2004
@@ -29,4 +29,7 @@
Option('', '--collectonly',
action="store_true", dest="collectonly", default=False,
help="only collect tests, don't execute them. "),
+ Option('', '--session',
+ action="store_true", dest="session", default=False,
+ help="run a test session to rerun only failing tests. "),
])
Modified: py/dist/py/test/run.py
==============================================================================
--- py/dist/py/test/run.py (original)
+++ py/dist/py/test/run.py Sat Oct 23 17:26:08 2004
@@ -14,6 +14,9 @@
self._instance = None
def run(self, obj):
+ raise ValueError
+
+ def run_collector_or_item(self, obj):
""" run (possibly many) testitems and/or collectors. """
collect = py.test.collect
if isinstance(obj, Item):
@@ -45,7 +48,7 @@
close = self.reporter.open(collector)
try:
for obj in collector:
- self.run(obj)
+ self.run_collector_or_item(obj)
finally:
if close:
close()
@@ -82,7 +85,7 @@
""" setup any neccessary resources. """
def teardown(self):
- """ teardown any resources the runner knows about. """
+ """ teardown any resources the driver knows about. """
while self._setupstack:
self._teardownone(self._setupstack.pop()[1])
@@ -129,9 +132,9 @@
self.name = pypath.basename
self.args = args
- def execute(self, runner):
- runner.setup_path(self.pypath)
- target, teardown = runner.setup_method(self.pypath)
+ def execute(self, driver):
+ driver.setup_path(self.pypath)
+ target, teardown = driver.setup_method(self.pypath)
try:
target(*self.args)
finally:
More information about the pytest-commit
mailing list