Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getLink(self, text=None, url=None, id=None, index=0):
"""See zope.testbrowser.interfaces.IBrowser"""
qa = 'a' if id is None else 'a#%s' % css_escape(id)
qarea = 'area' if id is None else 'area#%s' % css_escape(id)
html = self._html
links = html.select(qa)
links.extend(html.select(qarea))
matching = []
for elem in links:
matches = (isMatching(elem.text, text) and
isMatching(elem.get('href', ''), url))
if matches:
matching.append(elem)
if index >= len(matching):
raise LinkNotFoundError()
elem = matching[index]
def test_escape_numbers(self):
"""Test escape hyphen cases."""
self.assertEqual(r'\33 ', sv.escape('3'))
self.assertEqual(r'-\33 ', sv.escape('-3'))
self.assertEqual(r'--3', sv.escape('--3'))
def test_escape_hyphen(self):
"""Test escape hyphen cases."""
self.assertEqual(r'\-', sv.escape('-'))
self.assertEqual(r'--', sv.escape('--'))
def test_escape_numbers(self):
"""Test escape hyphen cases."""
self.assertEqual(r'\33 ', sv.escape('3'))
self.assertEqual(r'-\33 ', sv.escape('-3'))
self.assertEqual(r'--3', sv.escape('--3'))
def test_escape_null(self):
"""Test escape null character."""
self.assertEqual('\ufffdtest', sv.escape('\x00test'))
def test_escape_special(self):
"""Test escape special character."""
self.assertEqual(r'\{\}\[\]\ \(\)', sv.escape('{}[] ()'))
def test_escape_ctrl(self):
"""Test escape control character."""
self.assertEqual(r'\1 test', sv.escape('\x01test'))
def test_escape_wide_unicode(self):
"""Test handling of wide Unicode."""
self.assertEqual('Emoji\\ \U0001F60D', sv.escape('Emoji \U0001F60D'))
def test_escape_hyphen(self):
"""Test escape hyphen cases."""
self.assertEqual(r'\-', sv.escape('-'))
self.assertEqual(r'--', sv.escape('--'))