Sha256: c285e5dcf206f1b11d3c8de08c88727bc270473f5b267d56c862d84a5e193c17

Contents?: true

Size: 966 Bytes

Versions: 30

Compression:

Stored size: 966 Bytes

Contents

from test_support import *

print_test('Subclassing Java from Python (test_jsubclass.py)', 1)

from java.lang import Runnable, Thread

# Overriding Methods

print_test('override methods', 2)
class MyThread(Thread):
	count = 0
	def run(self):
		self.count = self.count+1


t1 = MyThread()
t1.start()
t1.join()
assert t1.count == 1, 'subclassing java.lang.Thread'

print_test('pass subclass back to java', 2)

class MyRun(Runnable):
	count = 0
	def run(self):
		self.count = self.count+1

run = MyRun()
t = Thread(run)
t.start()
t.join()
assert run.count == 1, 'subclassing java.lang.Thread'

print_test("invoke super's constructor", 2)

class MyThread(Thread):
	def __init__(self):
		self.name = "Python-"+self.name

t = MyThread()
assert t.name[:14] == "Python-Thread-", 'automatic constructor call'

class MyThread(Thread):
	def __init__(self):
		Thread.__init__(self, "Python-Thread")

t = MyThread()
assert t.name == "Python-Thread", 'explicit constructor call'

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rubyfox-server-2.19.2.0 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.17.3.2 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.17.3.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.17.3.0 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.16.3.2 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.16.3.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.16.0.4 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.16.0.3 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.16.0.2 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.16.0.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.16.0.0 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.13.7.3 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.13.6.2 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.13.6.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.13.5.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.13.4.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.13.3.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.12.5.1 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.12.5.0 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py
rubyfox-server-2.12.4.0 lib/rubyfox/server/data/lib/Lib/test/test_jsubclass.py