[py-svn] r6995 - in py/dist: doc py py/path/fspy py/path/test py/test py/test/report/text py/test/test/data
hpk at codespeak.net
hpk at codespeak.net
Mon Oct 18 02:15:26 CEST 2004
Author: hpk
Date: Mon Oct 18 02:15:25 2004
New Revision: 6995
Modified:
py/dist/doc/future.txt
py/dist/doc/test.txt
py/dist/doc/why_py.txt
py/dist/py/__init__.py
py/dist/py/initpkg.py
py/dist/py/path/fspy/test_fspy.py
py/dist/py/path/test/common.py
py/dist/py/path/test/test_api.py
py/dist/py/test/cmdline.py
py/dist/py/test/collect.py
py/dist/py/test/compat.py
py/dist/py/test/report/text/reporter.py
py/dist/py/test/report/text/summary.py
py/dist/py/test/run.py
py/dist/py/test/test/data/Collector.py
py/dist/py/test/test_collect.py
Log:
some refactoring / renaming to make the documentation right :-)
- the test code now really deals with a Driver and test Items
and not a Runner and Units anymore. The caution notice
from the future text is removed etc.pp.
- the filesystem/python/root path formerly known as 'fspy'
is now called 'extpy'.
- fixed some documentation
Modified: py/dist/doc/future.txt
==============================================================================
--- py/dist/doc/future.txt (original)
+++ py/dist/doc/future.txt Mon Oct 18 02:15:25 2004
@@ -17,9 +17,9 @@
A more general view on ``py.path`` objects
==========================================
-Seen from a more general persective, the current ``py.path.fspy`` path
+Seen from a more general persective, the current ``py.path.extpy`` path
offers a way to go from a file to the structured content of
-a file, namely a python object. The ``fspy`` path retains some
+a file, namely a python object. The ``extpy`` path retains some
common ``path`` operations and semantics but offers additional
methods, e.g. ``resolve()`` gets you a true python object.
@@ -28,7 +28,7 @@
config files. While some tasks will only be possible
to perform in a domain specific manner (e.g. applying xslt
etc.pp) ``py.path`` offers a common behaviour for
-structured content paths. So far only ``py.path.fspy``
+structured content paths. So far only ``py.path.extpy``
is implemented and used by py.test to address tests
and traverse into test files.
@@ -52,7 +52,7 @@
directories as sections and files as option-names and the
content of the file as values.
-But it also works (today!) for ``fspy`` paths if you put the following
+But it also works (today!) for ``extpy`` paths if you put the following
python code in a file::
class Section1:
@@ -61,7 +61,7 @@
class Section2:
someoption = "i am another option value"
-An ``fspy()`` path maps classes and modules to directories and
+An ``extpy()`` path maps classes and modules to directories and
name-value bindings to file/read() operations.
And it could also work for 'xml' paths if you put
@@ -107,7 +107,7 @@
path objects should be stackable
--------------------------------
-Oh, and btw, a ``py.path.fspy`` file could live on top of a
+Oh, and btw, a ``py.path.extpy`` file could live on top of a
'py.path.xml' path as well, i.e. take::
<xml ...>
@@ -120,11 +120,11 @@
<exprinfo>
def getmsg(x): pass </exprino></magic></py></code>
-and use it to have a ``fspy`` path living on it::
+and use it to have a ``extpy`` path living on it::
p = py.path.local(xmlfilename)
xmlp = py.path.xml(p, 'py/magic/exprinfo')
- p = py.path.fspy(xmlp, 'getmsg')
+ p = py.path.extpy(xmlp, 'getmsg')
assert p.check(func=1, basename='getmsg')
getmsg = p.resolve()
Modified: py/dist/doc/test.txt
==============================================================================
--- py/dist/doc/test.txt (original)
+++ py/dist/doc/test.txt Mon Oct 18 02:15:25 2004
@@ -5,15 +5,6 @@
.. contents::
.. sectnum::
-*PLEASE NOTICE*:
- a few names like ``Driver`` and ``Item`` used in this document
- mostly represent a future naming, they are currently called differently,
- ``Runner`` and ``Unit`` respectively. The latter names are causing
- confusion with the ``unittest.py`` nomen clatura. ``py.test``
- takes a much more general view on testing and thus it should start
- out with a slightly different view. However, as a user you will
- not get in touch too quickly with these names, anyway. So calm down :-)
-
starting point: ``py.test`` command line tool
=============================================
@@ -30,7 +21,7 @@
def test_answer():
assert 42 == 43
-In contrast to ``unitest.py`` limitations you
+In contrast to ``unittest.py`` limitations you
can have test functions as well as test methods.
You can execute the test by invoking::
@@ -261,7 +252,7 @@
The ``driver`` invokes the iteration protocol, i.e. the
``__iter__`` method of Collectors. These methods yield more (sub)
-*collectors* or Test *Items*. They should usually not raise
+*Collectors* or test *Items*. They should usually not raise
exceptions but yield back a specific CollectError. This is to
avoid that a collecting error breaks the whole collection
chain. It is at the drivers discretion to react to errors
Modified: py/dist/doc/why_py.txt
==============================================================================
--- py/dist/doc/why_py.txt (original)
+++ py/dist/doc/why_py.txt Mon Oct 18 02:15:25 2004
@@ -83,7 +83,7 @@
Another focus is a well tested Path implementation that
supports different backends, currently a local filesystem and
subversion working copies and subversion remote URLs.
-Moreover, it provides an experimental fspython path to address
+Moreover, it provides an experimental extpython path to address
a Python object on the filesystem.
You may read some more regarding the future_ of the py lib.
Modified: py/dist/py/__init__.py
==============================================================================
--- py/dist/py/__init__.py (original)
+++ py/dist/py/__init__.py Mon Oct 18 02:15:25 2004
@@ -4,7 +4,7 @@
'path.checker': './path/common.checker',
'path.svnurl': './path/svn/urlcommand.SvnCommandPath',
'path.svnwc': './path/svn/wccommand.SvnWCCommandPath',
- 'path.fspy': './path/fspy/fspy.Fspy',
+ 'path.extpy': './path/fspy/fspy.Fspy',
'path.NotFound': './path/error.FileNotFound',
'path.Denied': './path/error.PermissionDenied',
'path.NoDirectory': './path/error.NoDirectory',
@@ -20,7 +20,7 @@
'test.raises': './test/raises.raises',
'test.config': './test/config.config',
'test.compat.TestCase': './test/compat.TestCase',
- 'test.Unit': './test/run.Unit',
+ 'test.Item': './test/run.Item',
'test.Option': './test/tool/optparse.Option',
'test.TextReporter': './test/report/text/reporter.TextReporter',
'test.MemoReporter': './test/report/memo.MemoReporter',
Modified: py/dist/py/initpkg.py
==============================================================================
--- py/dist/py/initpkg.py (original)
+++ py/dist/py/initpkg.py Mon Oct 18 02:15:25 2004
@@ -32,18 +32,18 @@
# inhibit further direct filesystem imports through the package module
del pkgmodule.__path__
- def _resolve(self, fspy):
+ def _resolve(self, extpy):
""" resolve a combined filesystem/python "fspy" path. """
- assert fspy.startswith('./'), \
- "%r is not an implementation path (XXX)" % fspy
+ assert extpy.startswith('./'), \
+ "%r is not an implementation path (XXX)" % extpy
- slash = fspy.rfind('/')
- dot = fspy.find('.', slash)
+ slash = extpy.rfind('/')
+ dot = extpy.find('.', slash)
if dot == -1:
- return self._loadimpl(fspy)
+ return self._loadimpl(extpy)
- implmodule = self._loadimpl(fspy[:dot])
- attrname = fspy[dot+1:]
+ implmodule = self._loadimpl(extpy[:dot])
+ attrname = extpy[dot+1:]
return getattr(implmodule, attrname)
def _loadimpl(self, relfile):
@@ -111,11 +111,11 @@
def __getattr__(self, name):
try:
- fspy = self.__map__[name]
+ extpy = self.__map__[name]
except KeyError:
raise AttributeError(name)
#print "getattr(%r, %r)" %(self, name)
- result = self.__package__._resolve(fspy)
+ result = self.__package__._resolve(extpy)
setattr(self, name, result)
del self.__map__[name]
# XXX modify some attrs to make a class appear at virtual module level
@@ -153,7 +153,7 @@
pkg = Package(pkgname, exportdefs)
seen = { pkgname : pkg.module }
- for pypath, fspy in pkg.exportitems():
+ for pypath, extpy in pkg.exportitems():
pyparts = pypath.split('.')
modparts = pyparts[:-1]
current = pkgname
@@ -170,6 +170,6 @@
if not hasattr(mod, '__map__'):
assert mod is pkg.module, \
"only root modules are allowed to be non-lazy. "
- setattr(mod, pyparts[-1], pkg._resolve(fspy))
+ setattr(mod, pyparts[-1], pkg._resolve(extpy))
else:
- mod.__map__[pyparts[-1]] = fspy
+ mod.__map__[pyparts[-1]] = extpy
Modified: py/dist/py/path/fspy/test_fspy.py
==============================================================================
--- py/dist/py/path/fspy/test_fspy.py (original)
+++ py/dist/py/path/fspy/test_fspy.py Mon Oct 18 02:15:25 2004
@@ -7,12 +7,12 @@
class TestFsPyCommonTests(common.CommonPathTests):
def setup_class(cls):
- cls.root = py.path.fspy(
+ cls.root = py.path.extpy(
py.magic.autopath().dirpath('inc_pseudofs.py'))
class TestFsPy:
def setup_class(cls):
- cls.root = py.path.fspy(mypath)
+ cls.root = py.path.extpy(mypath)
def test_join(self):
p = self.root.join('A')
@@ -147,11 +147,11 @@
class TestErrors:
def test_FileNotFound(self):
- p = py.path.fspy(mypath, 'somesuch')
+ p = py.path.extpy(mypath, 'somesuch')
py.test.raises(py.path.NotFound, p.resolve)
def test_FileNotFound_really(self):
- p = py.path.fspy(mypath.new(basename='notexist'), 'somesuch')
+ p = py.path.extpy(mypath.new(basename='notexist'), 'somesuch')
py.test.raises(py.path.NotFound, p.resolve)
#def test_ImportError():
Modified: py/dist/py/path/test/common.py
==============================================================================
--- py/dist/py/path/test/common.py (original)
+++ py/dist/py/path/test/common.py Mon Oct 18 02:15:25 2004
@@ -43,7 +43,7 @@
x = other.common(self.root)
assert x == self.root
- third = py.path.fspy('x', 'whatever')
+ third = py.path.extpy('x', 'whatever')
x = other.common(third)
assert x is None
Modified: py/dist/py/path/test/test_api.py
==============================================================================
--- py/dist/py/path/test/test_api.py (original)
+++ py/dist/py/path/test/test_api.py Mon Oct 18 02:15:25 2004
@@ -7,7 +7,7 @@
def repr_eval_test(self, p):
r = repr(p)
- from py.path import local,svnurl, svnwc, fspy
+ from py.path import local,svnurl, svnwc, extpy
y = eval(r)
assert y == p
Modified: py/dist/py/test/cmdline.py
==============================================================================
--- py/dist/py/test/cmdline.py (original)
+++ py/dist/py/test/cmdline.py Mon Oct 18 02:15:25 2004
@@ -32,7 +32,7 @@
collectors.append(test.collect.Directory(path.local()))
reporter = config.reporter
- runner = test.run.Runner(reporter)
+ runner = test.run.Driver(reporter)
runner.setup()
try:
try:
Modified: py/dist/py/test/collect.py
==============================================================================
--- py/dist/py/test/collect.py (original)
+++ py/dist/py/test/collect.py Mon Oct 18 02:15:25 2004
@@ -22,7 +22,7 @@
""" instances are *restartable iterators*. They will yield Units or
Collector instances during iteration.
"""
- Unit = test.run.Unit
+ Item = test.run.Item
def iterunits(self):
""" yield all units of the Collector instance. """
@@ -61,7 +61,7 @@
if self.rec(fspath):
yield self.__class__(fspath)
elif self.fil(fspath):
- yield Module(py.path.fspy(fspath))
+ yield Module(py.path.extpy(fspath))
except:
yield self._except()
@@ -70,24 +70,24 @@
# ----------------------------------------------
class PyCollector(Collector):
- def __init__(self, fspy):
- self.fspy = py.path.fspy(fspy)
+ def __init__(self, extpy):
+ self.extpy = py.path.extpy(extpy)
self.yielders = [getattr(self, x)
for x in dir(self.__class__)
if x.startswith('collect_')]
def __repr__(self):
- return '%s(%r)' %(self.__class__.__name__, str(self.fspy))
+ return '%s(%r)' %(self.__class__.__name__, str(self.extpy))
def __iter__(self):
try:
# we want to sort according to lineno, so here goes
# the generator lazyness
l = []
- for pypath in self.fspy.listdir():
+ for pypath in self.extpy.listdir():
for meth in self.yielders:
for x in meth(pypath):
- x.fspath = self.fspy.fspath
+ x.fspath = self.extpy.fspath
sortvalue = self.getsortvalue(x)
l.append((sortvalue, x))
l.sort()
@@ -100,7 +100,7 @@
""" sorting function to bring test methods in
the same order as int he file.
"""
- if isinstance(obj, self.Unit):
+ if isinstance(obj, self.Item):
obj = obj.pypath.resolve()
elif isinstance(obj, PyCollector):
for x in obj:
@@ -116,9 +116,9 @@
class Module(PyCollector):
def __iter__(self):
try:
- iter = self.fspy.join('Collector')
+ iter = self.extpy.join('Collector')
if iter.check(exists=True):
- iter = iter.resolve()(self.fspy)
+ iter = iter.resolve()(self.extpy)
else:
iter = super(Module, self).__iter__()
for x in iter:
@@ -128,12 +128,12 @@
def collect_function(self, pypath):
if pypath.check(func=1, basestarts='test_'):
- if self.fspy.samefile(pypath):
- yield self.Unit(pypath)
+ if self.extpy.samefile(pypath):
+ yield self.Item(pypath)
def collect_class(self, pypath):
#print "checking %r (pypath: %r)" % (pypath.resolve(), pypath)
- if pypath.check(basestarts='Test') and self.fspy.samefile(pypath):
+ if pypath.check(basestarts='Test') and self.extpy.samefile(pypath):
obj = pypath.resolve()
if inspect.isclass(obj) and not getattr(obj, 'disabled', 0):
yield Class(pypath)
@@ -145,5 +145,5 @@
# methods like in the Module Collector
if pypath.check(basestarts='test_', func=1):
func = pypath.resolve()
- yield getattr(func.im_class, 'Unit', self.Unit)(pypath)
+ yield getattr(func.im_class, 'Item', self.Item)(pypath)
Modified: py/dist/py/test/compat.py
==============================================================================
--- py/dist/py/test/compat.py (original)
+++ py/dist/py/test/compat.py Mon Oct 18 02:15:25 2004
@@ -1,7 +1,7 @@
from __future__ import generators
from py import test, magic
-class TestCaseUnit(test.run.Unit):
+class TestCaseUnit(test.run.Item):
""" compatibility Unit executor for TestCase methods
honouring setUp and tearDown semantics.
"""
@@ -18,7 +18,7 @@
class TestCase:
"""compatibility class of unittest's TestCase. """
- Unit = TestCaseUnit
+ Item = TestCaseUnit
def setUp(self):
pass
Modified: py/dist/py/test/report/text/reporter.py
==============================================================================
--- py/dist/py/test/report/text/reporter.py (original)
+++ py/dist/py/test/report/text/reporter.py Mon Oct 18 02:15:25 2004
@@ -93,26 +93,26 @@
self.out.line()
return close_directory
- def startunit(self, unit):
+ def startitem(self, item):
if not self.option.nocapture:
from py.__impl__.test.tool.outerrcapture import SimpleOutErrCapture
- unit.iocapture = SimpleOutErrCapture()
+ item.iocapture = SimpleOutErrCapture()
if self.out.tty:
- realpath, lineno = unit.pypath.getfilelineno()
- location = "running %s:%d %s" % (realpath.basename, lineno, str(unit.pypath.modpath))
+ realpath, lineno = item.pypath.getfilelineno()
+ location = "running %s:%d %s" % (realpath.basename, lineno, str(item.pypath.modpath))
self.out.rewrite(location)
- self._started[unit] = now()
+ self._started[item] = now()
- def endunit(self, result):
+ def enditem(self, result):
endtime = now()
- unit = result.unit
- starttime = self._started[unit]
- del self._started[unit]
+ item = result.item
+ starttime = self._started[item]
+ del self._started[item]
elapsed = endtime - starttime
- unit.elapsed = elapsed
+ item.elapsed = elapsed
if not self.option.nocapture:
- result.out, result.err = unit.iocapture.reset()
+ result.out, result.err = item.iocapture.reset()
restype, c = self.processresult(result)
writeinfo = None
@@ -127,11 +127,11 @@
self.out.write(c)
if writeinfo is not None:
- realpath, lineno = unit.pypath.getfilelineno()
+ realpath, lineno = item.pypath.getfilelineno()
location = "%s:%d" % (realpath.basename, lineno)
resultstring = self.namemap.get(restype, result.__class__.__name__)
self.out.rewrite("%.3f %-2s %-20s %s%s" % (
- elapsed, resultstring, location, str(unit.pypath.modpath), writeinfo
+ elapsed, resultstring, location, str(item.pypath.modpath), writeinfo
))
if self.option.usepdb:
if (issubclass(restype, collect.Error) or
Modified: py/dist/py/test/report/text/summary.py
==============================================================================
--- py/dist/py/test/report/text/summary.py (original)
+++ py/dist/py/test/report/text/summary.py Mon Oct 18 02:15:25 2004
@@ -90,7 +90,7 @@
#self.out.sep("_", "Test Failure") # %s" % res.unit.pypath)
#self.out.sep("_")
#self.out.line()
- self.repr_traceback(res.unit, res.excinfo[2],
+ self.repr_traceback(res.item, res.excinfo[2],
getattr(res, 'tbindex', -1))
#self.out.line()
self.repr_failure_result(res)
@@ -120,7 +120,7 @@
#self.out.line()
self.out.sep("- ", "traceback of unexpected exception")
#self.out.line("reality:")
- self.repr_traceback(res.unit, res.innerexcinfo[2])
+ self.repr_traceback(res.item, res.innerexcinfo[2])
for line in traceback.format_exception_only(*res.innerexcinfo[:2]):
self.out.line(line)
elif issubclass(cls, assertion.AssertionError):
@@ -187,10 +187,10 @@
tb = tb.tb_next
return old
- def repr_traceback(self, unit, tb, tbindex=-1):
- t_file, t_lineno = unit.pypath.getfilelineno()
- self.out.line("%s, line %d" % (unit.pypath, t_lineno) )
- fspath = unit.pypath.fspath
+ def repr_traceback(self, item, tb, tbindex=-1):
+ t_file, t_lineno = item.pypath.getfilelineno()
+ self.out.line("%s, line %d" % (item.pypath, t_lineno) )
+ fspath = item.pypath.fspath
self.out.sep('_')
self.repr_traceback_raw(fspath, tb, tbindex)
#t_file, t_lineno = unit.pypath.getfilelineno()
Modified: py/dist/py/test/run.py
==============================================================================
--- py/dist/py/test/run.py (original)
+++ py/dist/py/test/run.py Mon Oct 18 02:15:25 2004
@@ -3,7 +3,7 @@
import sys, inspect
from py import test
-class Runner:
+class Driver:
option = test.config.option
def __init__(self, reporter):
@@ -14,12 +14,12 @@
def run(self, obj):
""" run (possibly many) testitems and/or collectors. """
collect = test.collect
- if isinstance(obj, Unit):
+ if isinstance(obj, Item):
if not self.option.collectonly:
#if self.option.args:
# if str(obj.path).find(self.option.args[0]) == -1:
# return
- self.rununit(obj)
+ self.runitem(obj)
elif isinstance(obj, collect.Collector):
self.runcollector(obj)
elif isinstance(obj, collect.Error):
@@ -37,7 +37,7 @@
if self.option.exitfirstproblem:
raise SystemExit, 2
else:
- raise TypeError("%r is not a Unit or Info instance" % obj)
+ raise TypeError("%r is not a Item or Info instance" % obj)
def runcollector(self, collector):
close = self.reporter.open(collector)
@@ -48,18 +48,18 @@
if close:
close()
- def rununit(self, unit):
- self.reporter.startunit(unit)
+ def runitem(self, item):
+ self.reporter.startitem(item)
try:
- res = unit.execute(self) or Passed()
+ res = item.execute(self) or Passed()
except Outcome, res:
res.excinfo = sys.exc_info()
except (KeyboardInterrupt, SystemExit):
raise
except:
res = Failed(excinfo=sys.exc_info())
- res.unit = unit
- self.reporter.endunit(res)
+ res.item = item
+ self.reporter.enditem(res)
def setup_path(self, pypath):
""" setup objects along the path to the test-method
@@ -117,7 +117,7 @@
# ----------------------------------------------
# Basic Test Unit Executor
# ----------------------------------------------
-class Unit(object):
+class Item(object):
_setupcache = []
_lastinstance = None
Modified: py/dist/py/test/test/data/Collector.py
==============================================================================
--- py/dist/py/test/test/data/Collector.py (original)
+++ py/dist/py/test/test/data/Collector.py Mon Oct 18 02:15:25 2004
@@ -4,7 +4,7 @@
class Collector(collect.PyCollector):
def collect_function(self, pypath):
if pypath.check(func=1, basestarts='myprefix_'):
- yield self.Unit(pypath, pypath.basename)
+ yield self.Item(pypath, pypath.basename)
def myprefix_1(arg):
assert arg == 'myprefix_1'
Modified: py/dist/py/test/test_collect.py
==============================================================================
--- py/dist/py/test/test_collect.py (original)
+++ py/dist/py/test/test_collect.py Mon Oct 18 02:15:25 2004
@@ -10,7 +10,7 @@
def test_failing_import_execfile():
fn = datadir / 'failingimport.py'
- l = list(collect.Module(path.fspy(fn)))
+ l = list(collect.Module(path.extpy(fn)))
assert l
ex, = l
assert issubclass(ex.excinfo[0], ImportError)
@@ -42,16 +42,16 @@
assert issubclass(l2[0].excinfo[0], path.Invalid)
def test_disabled_class():
- fspy = path.fspy(datadir.join('disabled.py'))
- l = list(collect.Class(fspy))
+ extpy = path.extpy(datadir.join('disabled.py'))
+ l = list(collect.Class(extpy))
assert len(l) == 0
class TestCustomCollector:
def test_custom_collect(self):
l = list(collect.Module(datadir.join('Collector.py')))
assert len(l) == 3
- for unit in l:
- assert isinstance(unit, test.Unit)
+ for item in l:
+ assert isinstance(item, test.Item)
#for x in l2:
# assert isinstance(x, Unit)
# x.execute()
More information about the pytest-commit
mailing list