Skip to content

Commit

Permalink
- change the way options are reported for single-unvalued checkbox co…
Browse files Browse the repository at this point in the history
…ntrols

- other minor tweaks
  • Loading branch information
benji-york committed Jul 27, 2005
1 parent 61d34d8 commit fd46269
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions testbrowser/README.txt
Expand Up @@ -31,7 +31,7 @@ The contents of the current page are available:
</body>
</html>

Making assertions about page contents are easy.
Making assertions about page contents is easy.

>>> 'Simple Page' in browser.contents
True
Expand Down Expand Up @@ -488,7 +488,7 @@ There are various types of controls. They are demonstrated here.
>>> ctrl.multiple
True
>>> ctrl.options
['on']
[True]

- Checkbox Control (Single-Valued, Valued)

Expand Down
7 changes: 5 additions & 2 deletions testbrowser/browser.py
Expand Up @@ -213,15 +213,15 @@ def value():

def fget(self):
value = self.mech_control.value
if self.type == 'checkbox' and self.options == ['on']:
if self.type == 'checkbox' and self.options == [True]:
value = bool(value)
return value

def fset(self, value):
if self.mech_control.type == 'file':
self.mech_control.add_file(value)
return
if self.type == 'checkbox' and self.options == ['on']:
if self.type == 'checkbox' and self.options == [True]:
if value:
value = ['on']
else:
Expand All @@ -235,6 +235,9 @@ def clear(self):
@property
def options(self):
"""See zope.app.testing.testbrowser.interfaces.IControl"""
if (self.type == 'checkbox'
and self.mech_control.possible_items() == ['on']):
return [True]
try:
return self.mech_control.possible_items()
except:
Expand Down
2 changes: 1 addition & 1 deletion testbrowser/ftests/simple.html
Expand Up @@ -5,4 +5,4 @@
<body>
<h1>Simple Page</h1>
</body>
</html>
</html>

0 comments on commit fd46269

Please sign in to comment.