From: <fwi...@us...> - 2008-12-15 13:55:59
|
Revision: 5763 http://jython.svn.sourceforge.net/jython/?rev=5763&view=rev Author: fwierzbicki Date: 2008-12-15 13:55:49 +0000 (Mon, 15 Dec 2008) Log Message: ----------- Test for http://bugs.jython.org/issue600790 added. Most likely this bug was fixed by Charlie Groves when java-type-newstyle branch was merged. Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2008-12-14 23:58:41 UTC (rev 5762) +++ trunk/jython/Lib/test/test_list_jy.py 2008-12-15 13:55:49 UTC (rev 5763) @@ -1,30 +1,39 @@ import unittest import test.test_support -class ListTestCase(unittest.TestCase): - +class ListTest(unittest.TestCase): + def test_recursive_list_slices(self): x = [1,2,3,4,5] x[1:] = x + self.assertEquals(x, [1, 1, 2, 3, 4, 5], - "Recursive assignment to list slices failed") + "Recursive assignment to list slices failed") - def test_subclass_richcmp(self): - # http://bugs.jython.org/issue1115 - class Foo(list): - def __init__(self, dotstring): - list.__init__(self, map(int, dotstring.split("."))) - bar1 = Foo('1.2.3') - bar2 = Foo('1.2.4') - self.assert_(bar1 < bar2) - self.assert_(bar1 <= bar2) - self.assert_(bar2 > bar1) - self.assert_(bar2 >= bar1) + #From http://bugs.jython.org/issue600790 + def test_setget_override(self): + from java.util import ArrayList + from java.lang import String + class GoofyListMapThing (ArrayList): + def __init__(self): + self.silly = "Nothing" + + def __setitem__(self, key, element): + self.silly = "spam" + + def __getitem__(self, key): + self.silly = "eggs" + + glmt = GoofyListMapThing() + glmt['my-key'] = String('el1') + self.assertEquals(glmt.silly, "spam") + glmt['my-key'] + self.assertEquals(glmt.silly, "eggs") + def test_main(): - test.test_support.run_unittest(ListTestCase) + test.test_support.run_unittest(ListTest) - if __name__ == "__main__": test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-15 14:12:23
|
Revision: 5765 http://jython.svn.sourceforge.net/jython/?rev=5765&view=rev Author: fwierzbicki Date: 2008-12-15 14:12:18 +0000 (Mon, 15 Dec 2008) Log Message: ----------- Sigh, restore updates to test_list_jy.py that I blew away. Mainly test_subclass_richcmp and ListTest -> ListTestCase. Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2008-12-15 14:01:24 UTC (rev 5764) +++ trunk/jython/Lib/test/test_list_jy.py 2008-12-15 14:12:18 UTC (rev 5765) @@ -1,39 +1,50 @@ import unittest import test.test_support -class ListTest(unittest.TestCase): - +class ListTestCase(unittest.TestCase): + def test_recursive_list_slices(self): x = [1,2,3,4,5] x[1:] = x - self.assertEquals(x, [1, 1, 2, 3, 4, 5], - "Recursive assignment to list slices failed") + "Recursive assignment to list slices failed") + def test_subclass_richcmp(self): + # http://bugs.jython.org/issue1115 + class Foo(list): + def __init__(self, dotstring): + list.__init__(self, map(int, dotstring.split("."))) + bar1 = Foo('1.2.3') + bar2 = Foo('1.2.4') + self.assert_(bar1 < bar2) + self.assert_(bar1 <= bar2) + self.assert_(bar2 > bar1) + self.assert_(bar2 >= bar1) + #From http://bugs.jython.org/issue600790 def test_setget_override(self): from java.util import ArrayList from java.lang import String class GoofyListMapThing (ArrayList): - def __init__(self): self.silly = "Nothing" - + def __setitem__(self, key, element): self.silly = "spam" - + def __getitem__(self, key): self.silly = "eggs" - + glmt = GoofyListMapThing() glmt['my-key'] = String('el1') self.assertEquals(glmt.silly, "spam") glmt['my-key'] self.assertEquals(glmt.silly, "eggs") - + def test_main(): - test.test_support.run_unittest(ListTest) + test.test_support.run_unittest(ListTestCase) + if __name__ == "__main__": test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-03 21:39:17
|
Revision: 6290 http://jython.svn.sourceforge.net/jython/?rev=6290&view=rev Author: pjenvey Date: 2009-05-03 21:39:08 +0000 (Sun, 03 May 2009) Log Message: ----------- make runnable on CPython, cleanup Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-05-03 20:56:51 UTC (rev 6289) +++ trunk/jython/Lib/test/test_list_jy.py 2009-05-03 21:39:08 UTC (rev 6290) @@ -1,5 +1,8 @@ import unittest -import test.test_support +from test import test_support +if test_support.is_jython: + from java.util import ArrayList + from java.lang import String class ListTestCase(unittest.TestCase): @@ -21,21 +24,21 @@ self.assert_(bar2 > bar1) self.assert_(bar2 >= bar1) - #From http://bugs.jython.org/issue600790 def test_setget_override(self): - from java.util import ArrayList - from java.lang import String + if not test_support.is_jython: + return - class GoofyListMapThing (ArrayList): + # http://bugs.jython.org/issue600790 + class GoofyListMapThing(ArrayList): def __init__(self): self.silly = "Nothing" - + def __setitem__(self, key, element): self.silly = "spam" - + def __getitem__(self, key): self.silly = "eggs" - + glmt = GoofyListMapThing() glmt['my-key'] = String('el1') self.assertEquals(glmt.silly, "spam") @@ -44,9 +47,9 @@ def test_tuple_equality(self): self.assertEqual([(1,), [1]].count([1]), 1) # http://bugs.jython.org/issue1317 - + def test_main(): - test.test_support.run_unittest(ListTestCase) + test_support.run_unittest(ListTestCase) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-06-05 13:13:03
|
Revision: 6451 http://jython.svn.sourceforge.net/jython/?rev=6451&view=rev Author: zyasoft Date: 2009-06-05 13:13:00 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Added basic thread safety test case for #521701 Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-06-05 04:39:58 UTC (rev 6450) +++ trunk/jython/Lib/test/test_list_jy.py 2009-06-05 13:13:00 UTC (rev 6451) @@ -1,5 +1,8 @@ import unittest +import threading +import time from test import test_support + if test_support.is_jython: from java.util import ArrayList from java.lang import String @@ -48,8 +51,34 @@ def test_tuple_equality(self): self.assertEqual([(1,), [1]].count([1]), 1) # http://bugs.jython.org/issue1317 +class ThreadSafetyTestCase(unittest.TestCase): + + def setUp(self): + self.globalList = [] + self.threads = [] + + def test_append_remove(self): + # derived from Itamar Shtull-Trauring's test for issue 521701 + def tester(): + ct = threading.currentThread() + for i in range(1000): + self.globalList.append(ct) + time.sleep(0.0001) + self.globalList.remove(ct) + for i in range(10): + t = threading.Thread(target=tester) + t.start() + self.threads.append(t) + + for t in self.threads: + t.join(1.) + for t in self.threads: + self.assertFalse(t.isAlive()) + self.assertEqual(self.globalList, []) + + def test_main(): - test_support.run_unittest(ListTestCase) + test_support.run_unittest(ListTestCase, ThreadSafetyTestCase) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-06-05 15:51:03
|
Revision: 6452 http://jython.svn.sourceforge.net/jython/?rev=6452&view=rev Author: zyasoft Date: 2009-06-05 15:50:54 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Minor enhancement of thread safety test case Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-06-05 13:13:00 UTC (rev 6451) +++ trunk/jython/Lib/test/test_list_jy.py 2009-06-05 15:50:54 UTC (rev 6452) @@ -1,4 +1,5 @@ import unittest +import random import threading import time from test import test_support @@ -53,30 +54,54 @@ class ThreadSafetyTestCase(unittest.TestCase): - def setUp(self): - self.globalList = [] - self.threads = [] + def run_threads(self, f, num=10): + threads = [] + for i in xrange(num): + t = threading.Thread(target=f) + t.start() + threads.append(t) + for t in threads: + t.join(1.) + for t in threads: + self.assertFalse(t.isAlive()) def test_append_remove(self): # derived from Itamar Shtull-Trauring's test for issue 521701 + lst = [] def tester(): ct = threading.currentThread() for i in range(1000): - self.globalList.append(ct) + lst.append(ct) time.sleep(0.0001) - self.globalList.remove(ct) - for i in range(10): - t = threading.Thread(target=tester) - t.start() - self.threads.append(t) - - for t in self.threads: - t.join(1.) - for t in self.threads: - self.assertFalse(t.isAlive()) - self.assertEqual(self.globalList, []) + lst.remove(ct) + self.run_threads(tester) + self.assertEqual(lst, []) + def test_sort(self): + lst = [] + def tester(): + ct = threading.currentThread() + for i in range(1000): + lst.append(ct) + lst.sort() + lst.remove(ct) + time.sleep(0.0001) + self.run_threads(tester) + self.assertEqual(lst, []) + def test_count_reverse(self): + lst = [0,1,2,3,4,5,6,7,8,9,10,0] + def tester(): + ct = threading.currentThread() + for i in range(1000): + self.assertEqual(lst[0], 0) + if random.random() > 0.5: + time.sleep(0.0001) + lst.reverse() + self.assertEqual(lst.count(0), 2) + self.assert_(lst[1] in (1,10)) + self.run_threads(tester) + def test_main(): test_support.run_unittest(ListTestCase, ThreadSafetyTestCase) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-06-06 01:09:40
|
Revision: 6453 http://jython.svn.sourceforge.net/jython/?rev=6453&view=rev Author: zyasoft Date: 2009-06-06 01:09:38 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Relaxed timeout for thread safety tests for architectures with somewhat slower execution. Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-06-05 15:50:54 UTC (rev 6452) +++ trunk/jython/Lib/test/test_list_jy.py 2009-06-06 01:09:38 UTC (rev 6453) @@ -60,8 +60,10 @@ t = threading.Thread(target=f) t.start() threads.append(t) + timeout = 10. # be especially generous for t in threads: - t.join(1.) + t.join(timeout) + timeout = 0. for t in threads: self.assertFalse(t.isAlive()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |