Skip to content

Commit

Permalink
Fix mechRepr on controls to always return a native str
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Jun 15, 2018
1 parent 37a1387 commit 049e937
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ CHANGES

- Drop support for Python 3.3 and 3.4.

- Fix ``mechRepr`` of CheckboxListControl to always return a native str.


5.2.4 (2017-11-24)
------------------
Expand Down
3 changes: 2 additions & 1 deletion src/zope/testbrowser/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,8 @@ def clear(self):
self.value = []

def mechRepr(self):
return "<SelectControl(%s=[*, ambiguous])>" % self.name
return "<SelectControl(%s=[*, ambiguous])>" % self.browser.toStr(
self.name)

@Lazy
def labels(self):
Expand Down
9 changes: 9 additions & 0 deletions src/zope/testbrowser/tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def setUp(self):
<select name="sel1">
<option value="op">Türn</option>
</select>
<input name="check1" type="checkbox" value="šêlėçtèd" />
<input name="sub1" type="submit" value="Yës" />
</form>
</body>
Expand All @@ -157,6 +158,14 @@ def test_ItemControl_has_str_mechRepr(self):
"<Item name='op' id=None contents='Türn' value='op'"
" label='Türn'>")

def test_CheckboxListControl_has_str_mechRepr(self):
from ..browser import CheckboxListControl
ctrl = self.browser.getControl(name='check1')
self.assertIsInstance(ctrl, CheckboxListControl)
mech_repr = ctrl.mechRepr()
self.assertIsInstance(mech_repr, str)
self.assertEqual(mech_repr, '<SelectControl(check1=[*, ambiguous])>')

def test_SubmitControl_has_str_mechRepr(self):
mech_repr = self.browser.getControl(name='sub1').mechRepr()
self.assertIsInstance(mech_repr, str)
Expand Down

0 comments on commit 049e937

Please sign in to comment.