[Zope3-checkins] SVN: Zope3/trunk/src/zope/testbrowser/ Fix edge-case bug in finding labels and add test.

Gary Poster gary at zope.com
Thu Nov 10 14:36:25 EST 2005


Log message for revision 40035:
  Fix edge-case bug in finding labels and add test.
  
  

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	2005-11-10 18:13:20 UTC (rev 40034)
+++ Zope3/trunk/src/zope/testbrowser/README.txt	2005-11-10 19:36:25 UTC (rev 40035)
@@ -333,6 +333,8 @@
     Traceback (most recent call last):
     ...
     LookupError: label 'hitespace'
+    >>> browser.getControl('[non word characters should not confuse]')
+    <Control name='non-word-characters' type='text'>
 
 Multiple labels can refer to the same control (simply because that is possible
 in the HTML 4.0 spec).

Modified: Zope3/trunk/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/browser.py	2005-11-10 18:13:20 UTC (rev 40034)
+++ Zope3/trunk/src/zope/testbrowser/browser.py	2005-11-10 19:36:25 UTC (rev 40035)
@@ -264,7 +264,7 @@
 
     def _findByLabel(self, label, forms, include_subcontrols=False):
         # forms are iterable of mech_forms
-        matches = re.compile(r'(^|\b|\s)%s(\b|\s|$)'
+        matches = re.compile(r'(^|\b|\W)%s(\b|\W|$)'
                              % re.escape(compressText(label))).search
         found = []
         for f in forms:

Modified: Zope3/trunk/src/zope/testbrowser/ftests/controls.html
===================================================================
--- Zope3/trunk/src/zope/testbrowser/ftests/controls.html	2005-11-10 18:13:20 UTC (rev 40034)
+++ Zope3/trunk/src/zope/testbrowser/ftests/controls.html	2005-11-10 19:36:25 UTC (rev 40035)
@@ -152,6 +152,13 @@
       </div>
 
       <div>
+        <label for="non-word-characters">*[non word characters should not
+          confuse]</label>
+        <input type="text" name="non-word-characters"
+               id="non-word-characters" />
+      </div>
+
+      <div>
         <label for="two-labels">Multiple labels really</label>
         <label for="two-labels">really are possible</label>
         <input type="text" name="two-labels"



More information about the Zope3-Checkins mailing list