From: <zy...@us...> - 2008-09-13 19:02:59
|
Revision: 5327 http://jython.svn.sourceforge.net/jython/?rev=5327&view=rev Author: zyasoft Date: 2008-09-13 19:02:55 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Tests that __module__ is available during class definition time, for #1022 Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2008-09-13 18:37:31 UTC (rev 5326) +++ trunk/jython/Lib/test/test_class_jy.py 2008-09-13 19:02:55 UTC (rev 5327) @@ -288,14 +288,26 @@ self.assertEqual(String.__module__, "java.lang") +module_name = __name__ +class ClassDefinesDunderModule(unittest.TestCase): + """Verifies http://bugs.jython.org/issue1022 is fixed""" + def test_dundermodule_in_classdef(self): + class Foo: + self.assertEqual(__module__, module_name) + class Bar(object): + self.assertEqual(__module__, module_name) + + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, BrokenNameTestCase, ClassLocalsTestCase, IsDescendentTestCase, - JavaClassNamingTestCase) + JavaClassNamingTestCase, + ClassDefinesDunderModule, + ) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-04-10 06:33:05
|
Revision: 6205 http://jython.svn.sourceforge.net/jython/?rev=6205&view=rev Author: pjenvey Date: 2009-04-10 06:33:04 +0000 (Fri, 10 Apr 2009) Log Message: ----------- use the types module instead of the pending deprecation new, whitespace Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2009-04-10 05:01:22 UTC (rev 6204) +++ trunk/jython/Lib/test/test_class_jy.py 2009-04-10 06:33:04 UTC (rev 6205) @@ -4,7 +4,7 @@ Made for Jython """ import __builtin__ -import new +import types import unittest from java.lang import Object from test import test_support @@ -34,7 +34,6 @@ self.assert_(str(Bar()).startswith('<%s.Bar object at' % __name__)) self.assert_(str(Baz()).startswith("org.python.proxies.%s$Baz" % __name__)) - def test_builtin_attributes(self): for attr, val in dict(__name__='foo', __module__='bar', __dict__={}, __flags__=1, __base__=object, @@ -119,7 +118,7 @@ pass def hello(self): return 'hello' - Bar = new.classobj('Bar', (Foo,), dict(hello=hello)) + Bar = types.ClassType('Bar', (Foo,), dict(hello=hello)) self.assert_(type(Bar), type) self.assert_(issubclass(Bar, Foo)) self.assert_(hasattr(Bar, 'hello')) @@ -183,8 +182,8 @@ def __getitem__(self, key): raise IndexError, "Fraid not" self.assertRaises(IndexError, A().__getitem__, 'b') - + class ClassNamelessModuleTestCase(unittest.TestCase): def setUp(self): @@ -306,15 +305,12 @@ class JavaClassNamingTestCase(unittest.TestCase): - """ - Tests for PyJavaClass naming. - """ + """Tests for PyJavaClass naming.""" + def test_java_class_name(self): - """ - The __name__ and __module__ attributes of Java classes should be set - according to the same convention that Python uses. - """ + # The __name__ and __module__ attributes of Java classes should + # be set according to the same convention that Python uses. from java.lang import String self.assertEqual(String.__name__, "String") self.assertEqual(String.__module__, "java.lang") @@ -323,7 +319,9 @@ module_name = __name__ class ClassDefinesDunderModule(unittest.TestCase): + """Verifies http://bugs.jython.org/issue1022 is fixed""" + def test_dundermodule_in_classdef(self): class Foo: self.assertEqual(__module__, module_name) @@ -359,17 +357,17 @@ # type.__str__ previously broke this self.assertEqual(str(Bar), 'foo') - + def test_main(): - test_support.run_unittest(ClassGeneralTestCase, - ClassNamelessModuleTestCase, - BrokenNameTestCase, - ClassLocalsTestCase, - IsDescendentTestCase, - JavaClassNamingTestCase, - ClassDefinesDunderModule, - ClassMetaclassRepr, - ) + test_support.run_unittest( + ClassGeneralTestCase, + ClassNamelessModuleTestCase, + BrokenNameTestCase, + ClassLocalsTestCase, + IsDescendentTestCase, + JavaClassNamingTestCase, + ClassDefinesDunderModule, + ClassMetaclassRepr) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |