[svn r37696] removing py.test.compat.TestCase - it's small

code but nobody uses it i think and there is
no documentation.

--HG--
branch : trunk
This commit is contained in:
hpk 2007-01-31 22:55:30 +01:00
parent 7970591813
commit f915de1992
4 changed files with 2 additions and 115 deletions

View File

@ -9,8 +9,8 @@ version = "0.8.80-alpha2"
initpkg(__name__,
description = "py.test and the py lib",
revision = int('$LastChangedRevision: 37641 $'.split(':')[1][:-1]),
lastchangedate = '$LastChangedDate: 2007-01-30 23:22:15 +0100 (Tue, 30 Jan 2007) $',
revision = int('$LastChangedRevision: 37696 $'.split(':')[1][:-1]),
lastchangedate = '$LastChangedDate: 2007-01-31 22:55:30 +0100 (Wed, 31 Jan 2007) $',
version = version,
url = "http://codespeak.net/py",
download_url = "http://codespeak.net/download/py/%s.tar.gz" %(version,),
@ -29,7 +29,6 @@ initpkg(__name__,
'test.skip' : ('./test/item.py', 'skip'),
'test.fail' : ('./test/item.py', 'fail'),
'test.exit' : ('./test/session.py', 'exit'),
'test.compat.TestCase' : ('./test/compat.py', 'TestCase'),
# configuration/initialization related test api
'test.config' : ('./test/config.py', 'config_per_process'),

View File

@ -49,12 +49,10 @@ def test_virtual_module_identity():
def test_importall():
base = py.path.local(py.__file__).dirpath()
nodirs = (
base.join('test', 'tkinter'),
base.join('test', 'testing', 'data'),
base.join('apigen', 'tracer', 'testing', 'package'),
base.join('test', 'testing', 'test'),
base.join('magic', 'greenlet.py'),
base.join('path', 'extpy', 'testing', 'test_data'),
base.join('path', 'gateway',),
base.join('doc',),
base.join('rest', 'directive.py'),
@ -63,7 +61,6 @@ def test_importall():
base.join('magic', 'greenlet.py'),
base.join('bin'),
base.join('execnet', 'script'),
base.join('compat'),
)
for p in base.visit('*.py', lambda x: x.check(dotfile=0)):
if p.basename == '__init__.py':

View File

@ -1,58 +0,0 @@
from __future__ import generators
import py
class TestCaseUnit(py.test.Function):
""" compatibility Unit executor for TestCase methods
honouring setUp and tearDown semantics.
"""
def execute(self, session):
boundmethod = self.obj
instance = boundmethod.im_self
instance.setUp()
try:
boundmethod()
finally:
instance.tearDown()
return py.test.Item.Passed()
class TestCase:
"""compatibility class of unittest's TestCase. """
Function = TestCaseUnit
def setUp(self):
pass
def tearDown(self):
pass
def fail(self, msg=None):
""" fail immediate with given message. """
raise py.test.Item.Failed(msg=msg)
def assertRaises(self, excclass, func, *args, **kwargs):
py.test.raises(excclass, func, *args, **kwargs)
failUnlessRaises = assertRaises
# dynamically construct (redundant) methods
aliasmap = [
('x', 'not x', 'assert_, failUnless'),
('x', 'x', 'failIf'),
('x,y', 'x!=y', 'failUnlessEqual,assertEqual, assertEquals'),
('x,y', 'x==y', 'failIfEqual,assertNotEqual, assertNotEquals'),
]
items = []
for sig, expr, names in aliasmap:
names = map(str.strip, names.split(','))
sigsubst = expr.replace('y', '%s').replace('x', '%s')
for name in names:
items.append("""
def %(name)s(self, %(sig)s):
__tracebackhide__ = True
if %(expr)s:
raise py.test.Item.Failed(msg=%(sigsubst)r %% (%(sig)s))
""" % locals() )
source = "".join(items)
exec py.code.Source(source).compile()
__all__ = ['TestCase']

View File

@ -1,51 +0,0 @@
from __future__ import generators
import py
class TestCompatTestCaseSetupSemantics(py.test.compat.TestCase):
globlist = []
def setUp(self):
self.__dict__.setdefault('l', []).append(42)
self.globlist.append(self)
def tearDown(self):
self.l.pop()
def test_issetup(self):
l = self.l
assert len(l) == 1
assert l[-1] == 42
#self.checkmultipleinstances()
def test_issetup2(self):
l = self.l
assert len(l) == 1
assert l[-1] == 42
#self.checkmultipleinstances()
#def checkmultipleinstances(self):
# for x,y in zip(self.globlist, self.globlist[1:]):
# assert x is not y
class TestCompatAssertions(py.test.compat.TestCase):
nameparamdef = {
'failUnlessEqual,assertEqual,assertEquals': ('1, 1', '1, 0'),
'assertNotEquals,failIfEqual': ('0, 1', '0,0'),
'failUnless,assert_': ('1', 'None'),
'failIf': ('0', '1'),
}
sourcelist = []
for names, (paramok, paramfail) in nameparamdef.items():
for name in names.split(','):
source = """
def test_%(name)s(self):
self.%(name)s(%(paramok)s)
#self.%(name)s(%(paramfail)s)
def test_%(name)s_failing(self):
self.assertRaises(py.test.Item.Failed,
self.%(name)s, %(paramfail)s)
""" % locals()
co = py.code.Source(source).compile()
exec co