예제 #1
0
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
예제 #2
0
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}"'
예제 #3
0
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
예제 #4
0
def test_quote(identifier, expected):
    assert lang.quote(identifier) == expected
예제 #5
0
 def test_quote_quotes(self):
     self.assertEqual(quote('"spam"'), r'"\"spam\""')
예제 #6
0
 def test_quote_keyword(self):
     self.assertEqual(quote('node'), '"node"')
     self.assertEqual(quote('EDGE'), '"EDGE"')
     self.assertEqual(quote('Graph'), '"Graph"')
예제 #7
0
def test_quote_quotes():
    assert quote('"spam"') == r'"\"spam\""'
예제 #8
0
def test_quote_keyword():
    assert quote('node') == '"node"'
    assert quote('EDGE') == '"EDGE"'
    assert quote('Graph') == '"Graph"'
예제 #9
0
 def test_quote_quotes(self):
     self.assertEqual(quote('"spam"'), r'"\"spam\""')
예제 #10
0
 def test_quote_keyword(self):
     self.assertEqual(quote('node'), '"node"')
     self.assertEqual(quote('EDGE'), '"EDGE"')
     self.assertEqual(quote('Graph'), '"Graph"')