[py-svn] py-trunk commit e0736a9c6877: kill unused code

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sat Jan 16 19:41:25 CET 2010


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1263667265 -3600
# Node ID e0736a9c6877d61b2eacdc92ce437a8795f78345
# Parent cd8564b53dee0a6eada8e73f9cd404d05c6c102b
kill unused code

--- a/py/_test/compat.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import py
-
-from py.test.collect import Function
-
-class TestCaseUnit(Function):
-    """ compatibility Unit executor for TestCase methods
-        honouring setUp and tearDown semantics.
-    """
-    def runtest(self, _deprecated=None):
-        boundmethod = self.obj 
-        instance = py.builtin._getimself(boundmethod)
-        instance.setUp()
-        try:
-            boundmethod()
-        finally:
-            instance.tearDown()
-
-class TestCase(object):
-    """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. """
-        py.test.fail(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, msg=""):
-                    __tracebackhide__ = True
-                    if %(expr)s:
-                        py.test.fail(msg=msg + (%(sigsubst)r %% (%(sig)s)))
-            """ % locals() )
-
-    source = "".join(items)
-    exec(py.code.Source(source).compile())
-
-__all__ = ['TestCase']

--- a/testing/test_compat.py
+++ /dev/null
@@ -1,53 +0,0 @@
-from __future__ import generators
-import py
-from py._test.compat import TestCase
-from py._test.outcome import Failed
-
-class TestCompatTestCaseSetupSemantics(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(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(Failed,
-                            self.%(name)s, %(paramfail)s)
-            """ % locals()
-            co = py.code.Source(source).compile()
-            exec(co)



More information about the pytest-commit mailing list