[Zope3-checkins] SVN: Zope3/trunk/src/zope/testbrowser/ Bugfix: for
logical consistency,
a select field with a label that is ambiguous with that of one of its
options should raise an ambiguity error. It was returning the
option.
Gary Poster
gary at zope.com
Mon Jul 10 21:03:45 EDT 2006
Log message for revision 69087:
Bugfix: for logical consistency, a select field with a label that is ambiguous with that of one of its options should raise an ambiguity error. It was returning the option.
Changed:
U Zope3/trunk/src/zope/testbrowser/README.txt
U Zope3/trunk/src/zope/testbrowser/browser.py
U Zope3/trunk/src/zope/testbrowser/ftests/controls.html
-=-
Modified: Zope3/trunk/src/zope/testbrowser/README.txt
===================================================================
--- Zope3/trunk/src/zope/testbrowser/README.txt 2006-07-10 21:20:45 UTC (rev 69086)
+++ Zope3/trunk/src/zope/testbrowser/README.txt 2006-07-11 01:03:43 UTC (rev 69087)
@@ -324,6 +324,14 @@
...
AmbiguityError: label 'Ambiguous Control'
+This is also true if an option in a control is ambiguous in relation to
+the control itself.
+
+ >>> browser.getControl('Sub-control Ambiguity')
+ Traceback (most recent call last):
+ ...
+ AmbiguityError: label 'Sub-control Ambiguity'
+
Ambiguous controls may be specified using an index value. We use the control's
value attribute to show the two controls; this attribute is properly introduced
below.
@@ -334,6 +342,10 @@
'First'
>>> browser.getControl('Ambiguous Control', index=1).value
'Second'
+ >>> browser.getControl('Sub-control Ambiguity', index=0)
+ <ListControl name='ambiguous-subcontrol' type='select'>
+ >>> browser.getControl('Sub-control Ambiguity', index=1).optionValue
+ 'ambiguous'
Label searches are against stripped, whitespace-normalized, no-tag versions of
the text. Text applied to searches is also stripped and whitespace normalized.
Modified: Zope3/trunk/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/browser.py 2006-07-10 21:20:45 UTC (rev 69086)
+++ Zope3/trunk/src/zope/testbrowser/browser.py 2006-07-11 01:03:43 UTC (rev 69087)
@@ -300,10 +300,14 @@
for f in forms:
for control in f.controls:
phantom = control.type in ('radio', 'checkbox')
+ if not phantom:
+ for l in control.get_labels():
+ if matches(l.text):
+ found.append((control, f))
+ break
if include_subcontrols and (
phantom or control.type=='select'):
- found_one = False
for i in control.items:
for l in i.get_labels():
if matches(l.text):
@@ -311,15 +315,6 @@
found_one = True
break
- if found_one:
- del found_one
- continue
-
- if not phantom:
- for l in control.get_labels():
- if matches(l.text):
- found.append((control, f))
- break
return found
def _findByName(self, name, forms):
Modified: Zope3/trunk/src/zope/testbrowser/ftests/controls.html
===================================================================
--- Zope3/trunk/src/zope/testbrowser/ftests/controls.html 2006-07-10 21:20:45 UTC (rev 69086)
+++ Zope3/trunk/src/zope/testbrowser/ftests/controls.html 2006-07-11 01:03:43 UTC (rev 69087)
@@ -183,7 +183,17 @@
</label>
</div>
+ <div>
+ If you have a select field with a label that overlaps with one of its
+ options' labels, that is ambiguous.
+ <label for="ambiguous-subcontrol">Sub-control Ambiguity</label>
+ <select name="ambiguous-subcontrol" id="ambiguous-subcontrol">
+ <option value="">(none)</option>
+ <option value="ambiguous">Sub-control Ambiguity Exemplified</option>
+ </select>
+ </div>
+
</form>
</body>
More information about the Zope3-Checkins
mailing list