Пример #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"')