agronholm / jython-swingutils (http://pypi.python.org/pypi/jython-swingutils/)
An assortment of utility classes and functions that ease the task of writing GUI applications with the Java Swing toolkit.
Clone this repository (size: 401.9 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/agronholm/jython-swingutils/
| commit 55: | da1103886b6f |
| parent 54: | 74aabf65866e |
| branch: | default |
Removed debugging cruft, adapted to changes in binding.py
Changed (Δ353 bytes):
raw changeset »
tests/test_binding.py (7 lines added, 14 lines removed)
Up to file-list tests/test_binding.py:
1 |
1 |
from nose.tools import eq_, raises, set_trace |
2 |
2 |
|
3 |
3 |
from swingutils.beans import AutoChangeNotifier |
4 |
from swingutils.binding import ValueHolder, |
|
4 |
from swingutils.binding import ValueHolder, bindProperty |
|
5 |
5 |
from swingutils.events import addPropertyListener |
6 |
6 |
|
7 |
7 |
|
| … | … | @@ -78,11 +78,9 @@ class TestValueHolder(object): |
78 |
78 |
listenerResult[0] = event |
79 |
79 |
|
80 |
80 |
listenerResult = [None] |
81 |
print "hasprop1=%s" % hasattr(self.holder, 'prop1') |
|
82 |
81 |
self.holder.value = self.bean1 |
83 |
82 |
addPropertyListener(self.bean1, 'prop1', listener, listenerResult) |
84 |
83 |
|
85 |
print "hasprop1=%s" % hasattr(self.holder, 'prop1') |
|
86 |
84 |
self.holder.prop1 = 'anotherValue' |
87 |
85 |
event = listenerResult[0] |
88 |
86 |
eq_(event.propertyName, 'prop1') |
| … | … | @@ -119,7 +117,7 @@ class TestConnect(object): |
119 |
117 |
self.bean2.prop1 = 'testVal2' |
120 |
118 |
|
121 |
119 |
def testOneWayNoSync(self): |
122 |
|
|
120 |
bindProperty(self.bean1, 'prop1', self.bean2, 'prop1') |
|
123 |
121 |
|
124 |
122 |
# Nothing should've changed yet |
125 |
123 |
eq_(self.bean1.prop1, 'testVal1') |
| … | … | @@ -131,7 +129,7 @@ class TestConnect(object): |
131 |
129 |
eq_(self.bean2.prop1, 'testVal3') |
132 |
130 |
|
133 |
131 |
def testOneWaySync(self): |
134 |
|
|
132 |
bindProperty(self.bean1, 'prop1', self.bean2, 'prop1', |
|
135 |
133 |
syncNow=True) |
136 |
134 |
|
137 |
135 |
# Bean2.prop1 should have changed |
| … | … | @@ -144,7 +142,7 @@ class TestConnect(object): |
144 |
142 |
eq_(self.bean2.prop1, 'testVal3') |
145 |
143 |
|
146 |
144 |
def testTwoWayNoSync(self): |
147 |
|
|
145 |
bindProperty(self.bean1, 'prop1', self.bean2, 'prop1', True) |
|
148 |
146 |
|
149 |
147 |
# Nothing should've changed yet |
150 |
148 |
eq_(self.bean1.prop1, 'testVal1') |
| … | … | @@ -161,7 +159,7 @@ class TestConnect(object): |
161 |
159 |
eq_(self.bean2.prop1, 'testVal4') |
162 |
160 |
|
163 |
161 |
def testTwoWaySync(self): |
164 |
|
|
162 |
bindProperty(self.bean1, 'prop1', self.bean2, 'prop1', True, True) |
|
165 |
163 |
|
166 |
164 |
# Bean2.prop1 should have changed |
167 |
165 |
eq_(self.bean1.prop1, 'testVal1') |
| … | … | @@ -178,7 +176,7 @@ class TestConnect(object): |
178 |
176 |
eq_(self.bean2.prop1, 'testVal4') |
179 |
177 |
|
180 |
178 |
def testConverter(self): |
181 |
|
|
179 |
bindProperty(self.bean1, 'prop1', self.bean2, 'prop1', |
|
182 |
180 |
converter=lambda v: 'xx%sxx' % v) |
183 |
181 |
|
184 |
182 |
# Nothing should've changed yet |
| … | … | @@ -190,13 +188,8 @@ class TestConnect(object): |
190 |
188 |
eq_(self.bean1.prop1, 'testVal3') |
191 |
189 |
eq_(self.bean2.prop1, 'xxtestVal3xx') |
192 |
190 |
|
193 |
@raises(AssertionError) |
|
194 |
def testTwowayConverter(self): |
|
195 |
connectProperties(self.bean1, 'prop1', self.bean2, 'prop1', True, |
|
196 |
converter=lambda v: 'xx%sxx' % v) |
|
197 |
||
198 |
191 |
def testDisconnect(self): |
199 |
adapter = |
|
192 |
adapter = bindProperty(self.bean1, 'prop1', self.bean2, 'prop1') |
|
200 |
193 |
|
201 |
194 |
# Nothing should've changed yet |
202 |
195 |
eq_(self.bean1.prop1, 'testVal1') |
