From: <pj...@us...> - 2009-05-06 05:20:50
|
Revision: 6301 http://jython.svn.sourceforge.net/jython/?rev=6301&view=rev Author: pjenvey Date: 2009-05-06 05:20:34 +0000 (Wed, 06 May 2009) Log Message: ----------- whitespace Modified Paths: -------------- trunk/jython/Lib/test/test_descr_jy.py Modified: trunk/jython/Lib/test/test_descr_jy.py =================================================================== --- trunk/jython/Lib/test/test_descr_jy.py 2009-05-05 21:12:43 UTC (rev 6300) +++ trunk/jython/Lib/test/test_descr_jy.py 2009-05-06 05:20:34 UTC (rev 6301) @@ -17,6 +17,7 @@ old = Old() new = New() + class TestDescrTestCase(unittest.TestCase): def test_class_dict_is_copy(self): @@ -393,12 +394,12 @@ except AttributeError, e: self.assertEquals("Custom message", str(e)) -# try to test more exhaustively binop overriding combination cases class Base(object): def __init__(self, name): self.name = name + def lookup_where(obj, name): mro = type(obj).__mro__ for t in mro: @@ -406,6 +407,7 @@ return t.__dict__[name], t return None, None + def refop(x, y, opname, ropname): # this has been validated by running the tests on top of cpython # so for the space of possibilities that the tests touch it is known @@ -418,14 +420,14 @@ if op is None and rop is not None: return rop(y, x) if rop and where1 is not where2: - if (issubclass(t2, t1) and not issubclass(where1, where2) - and not issubclass(t1, where2) - ): + if (issubclass(t2, t1) and not issubclass(where1, where2) and + not issubclass(t1, where2)): return rop(y, x) if op is None: return "TypeError" return op(x,y) + def do_test(X, Y, name, impl): x = X('x') y = Y('y') @@ -452,7 +454,7 @@ return f = lambda self, other: (n, self.name, other.name) - if n%2 == 0: + if n % 2 == 0: name = opname else: name = ropname @@ -462,23 +464,27 @@ continue if C is not object: setattr(C, name, f) - override_in_hier(n-1) - if C is not object: + override_in_hier(n - 1) + if C is not object: delattr(C, name) override_in_hier() #print count[0] return fail + class BinopCombinationsTestCase(unittest.TestCase): - + + """Try to test more exhaustively binop overriding combination + cases""" + def test_binop_combinations_mul(self): class X(Base): pass class Y(X): pass - fail = do_test(X, Y, 'mul', lambda x,y: x*y) + fail = do_test(X, Y, 'mul', lambda x, y: x*y) #print len(fail) self.assert_(not fail) @@ -488,9 +494,9 @@ class Y(X): pass - fail = do_test(X, Y, 'sub', lambda x,y: x-y) + fail = do_test(X, Y, 'sub', lambda x, y: x-y) #print len(fail) - self.assert_(not fail) + self.assert_(not fail) def test_binop_combinations_pow(self): class X(Base): @@ -498,9 +504,9 @@ class Y(X): pass - fail = do_test(X, Y, 'pow', lambda x,y: x**y) + fail = do_test(X, Y, 'pow', lambda x, y: x**y) #print len(fail) - self.assert_(not fail) + self.assert_(not fail) def test_binop_combinations_more_exhaustive(self): class X(Base): @@ -524,10 +530,11 @@ class Y(C1, X1, C2): pass - fail = do_test(X, Y, 'sub', lambda x,y: x-y) + fail = do_test(X, Y, 'sub', lambda x, y: x - y) #print len(fail) self.assert_(not fail) + def test_main(): test_support.run_unittest(TestDescrTestCase, SubclassDescrTestCase, @@ -536,5 +543,6 @@ GetAttrTestCase, BinopCombinationsTestCase) + if __name__ == '__main__': test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |