From f915de1992b0795ec5534c166d28da878e84ed82 Mon Sep 17 00:00:00 2001 From: hpk Date: Wed, 31 Jan 2007 22:55:30 +0100 Subject: [PATCH] [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 --- py/__init__.py | 5 ++- py/misc/testing/test_initpkg.py | 3 -- py/test/compat.py | 58 --------------------------------- py/test/testing/test_compat.py | 51 ----------------------------- 4 files changed, 2 insertions(+), 115 deletions(-) delete mode 100644 py/test/compat.py delete mode 100644 py/test/testing/test_compat.py diff --git a/py/__init__.py b/py/__init__.py index 4923288fc..75563709f 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -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'), diff --git a/py/misc/testing/test_initpkg.py b/py/misc/testing/test_initpkg.py index 551b1e00a..4fb0387d0 100644 --- a/py/misc/testing/test_initpkg.py +++ b/py/misc/testing/test_initpkg.py @@ -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': diff --git a/py/test/compat.py b/py/test/compat.py deleted file mode 100644 index 19a952c56..000000000 --- a/py/test/compat.py +++ /dev/null @@ -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'] diff --git a/py/test/testing/test_compat.py b/py/test/testing/test_compat.py deleted file mode 100644 index 51d03e392..000000000 --- a/py/test/testing/test_compat.py +++ /dev/null @@ -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