[Checkins] SVN: gocept.selenium/trunk/ added an assert type 'list', applied it to getAllWindow*
Thomas Lotze
tl at gocept.com
Wed Nov 30 06:24:50 UTC 2011
Log message for revision 123544:
added an assert type 'list', applied it to getAllWindow*
Changed:
U gocept.selenium/trunk/CHANGES.txt
U gocept.selenium/trunk/src/gocept/selenium/selenese.py
-=-
Modified: gocept.selenium/trunk/CHANGES.txt
===================================================================
--- gocept.selenium/trunk/CHANGES.txt 2011-11-29 18:32:00 UTC (rev 123543)
+++ gocept.selenium/trunk/CHANGES.txt 2011-11-30 06:24:49 UTC (rev 123544)
@@ -4,7 +4,8 @@
0.13 (unreleased)
-----------------
-- Nothing changed yet.
+- Added a selenese assert type 'list' and added it to the window management
+ query methods.
0.12 (2011-11-29)
Modified: gocept.selenium/trunk/src/gocept/selenium/selenese.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/selenese.py 2011-11-29 18:32:00 UTC (rev 123543)
+++ gocept.selenium/trunk/src/gocept/selenium/selenese.py 2011-11-30 06:24:49 UTC (rev 123544)
@@ -410,14 +410,17 @@
'No alert occured.')
return self.selenium.get_alert()
+ @assert_type('list')
@passthrough
def getAllWindowIds(self):
pass
+ @assert_type('list')
@passthrough
def getAllWindowNames(self):
pass
+ @assert_type('list')
@passthrough
def getAllWindowTitles(self):
pass
@@ -685,6 +688,9 @@
elif getter.assert_type == 'locator_pattern':
return lambda locator, pattern: self._assert_pattern(
getter, requested_name, pattern, locator)
+ elif getter.assert_type == 'list':
+ return lambda expected: self._assert_list(
+ getter, requested_name, expected)
elif getter.assert_type is None:
return lambda: self._assert(getter, requested_name)
else:
@@ -705,6 +711,31 @@
'Expected: %r, got: %r from %s' %
(pattern, result, self._call_repr(name, *args)))
+ def _assert_list(self, getter, name, expected):
+ result = getter()
+ if expected != result:
+ detail = ''
+ if len(expected) != len(result):
+ detail += ('Expected %s items, got %s items.\n' %
+ (len(expected), len(result)))
+ if len(expected) < len(result):
+ detail += ('First extra element: %r\n\n' %
+ (result[len(expected)],))
+ elif len(expected) > len(result):
+ detail += ('First missing element: %r\n\n' %
+ (expected[len(result)],))
+ else:
+ for i, x in enumerate(expected):
+ if x != result[i]:
+ detail += (
+ 'First differing list item at index %s:\n'
+ '- %r\n+ %r\n\n' % (i, x, result[i]))
+ break
+ raise self.failureException(
+ detail + ('Expected: %s,\ngot: %s\nfrom %s' % (
+ abbrev_repr(expected), abbrev_repr(result),
+ self._call_repr(name))))
+
def _negate(self, assertion, name, *args, **kw):
try:
assertion(*args, **kw)
@@ -778,3 +809,10 @@
except KeyError:
pass
return matcher(text, pattern)
+
+
+def abbrev_repr(x, size=70):
+ r = repr(x)
+ if len(r) > size:
+ r = r[:size-3] + '...'
+ return r
More information about the checkins
mailing list