def test_nohtml(string, expected, expected_quoted): result = lang.nohtml(string) assert isinstance(result, str) assert isinstance(result, lang.NoHtml) assert result == expected quoted = lang.quote(result) assert isinstance(quoted, str) assert quoted == expected_quoted
def test_deprecated_escape(recwarn, char): warnings.simplefilter('always') escape = eval(rf'"\{char}"') assert len(recwarn) == 1 w = recwarn.pop(DeprecationWarning) assert str(w.message).startswith('invalid escape sequence') assert escape == f'\\{char}' assert lang.quote(escape) == f'"\\{char}"'
def test_deprecated_escape(recwarn, char): warnings.simplefilter('always') escape = eval(r'"\%s"' % char) if sys.version_info < (3, 6): assert not recwarn else: assert len(recwarn) == 1 w = recwarn.pop(DeprecationWarning) assert str(w.message).startswith('invalid escape sequence') assert escape == '\\%s' % char assert quote(escape) == '"\\%s"' % char
def test_quote(identifier, expected): assert lang.quote(identifier) == expected
def test_quote_quotes(self): self.assertEqual(quote('"spam"'), r'"\"spam\""')
def test_quote_keyword(self): self.assertEqual(quote('node'), '"node"') self.assertEqual(quote('EDGE'), '"EDGE"') self.assertEqual(quote('Graph'), '"Graph"')
def test_quote_quotes(): assert quote('"spam"') == r'"\"spam\""'
def test_quote_keyword(): assert quote('node') == '"node"' assert quote('EDGE') == '"EDGE"' assert quote('Graph') == '"Graph"'