Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_shorten(width, expected):
if isinstance(expected, six.string_types):
assert shorten(u'foobar', width) == expected
else:
with raises(expected):
shorten(u'foobar', width)
def __str__(self):
data = repr(shorten(self.get(), width=40))
return "<%s xpath=%r data=%s>" % (type(self).__name__, self._expr, data)
__repr__ = __str__