Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Comment('#Before blank\n'),
Whitespace('\n',),
Comment('#After blank\n'),
Whitespace('\n'),
KeyValue('before', 'blank', 'before=blank\n'),
Whitespace('\n'),
KeyValue('after', 'blank', 'after=blank\n'),
],
),
('key va\\\n lue\n', [KeyValue('key', 'value', 'key va\\\n lue\n')]),
('key va\\\n', [KeyValue('key', 'va', 'key va\\\n')]),
('key va\\', [KeyValue('key', 'va', 'key va\\')]),
(' \\\n\t\\\r\n\f\\\r \n', [Whitespace(' \\\n\t\\\r\n\f\\\r \n')]),
(
'key = v\\\n\ta\\\r\n\fl\\\r u\\\ne\n',
[KeyValue('key', 'value', 'key = v\\\n\ta\\\r\n\fl\\\r u\\\ne\n')],
),
def test_comment_attributes():
c = Comment('a')
assert c.source == 'a'
Comment(' ! Also a comment\n'),
],
),
(
'#Before blank\n'
'\n'
'#After blank\n'
'\n'
'before=blank\n'
'\n'
'after=blank\n',
[
Comment('#Before blank\n'),
Whitespace('\n',),
Comment('#After blank\n'),
Whitespace('\n'),
KeyValue('before', 'blank', 'before=blank\n'),
Comment('#After blank\n'),
Whitespace('\n'),
KeyValue('before', 'blank', 'before=blank\n'),
Whitespace('\n'),
KeyValue('after', 'blank', 'after=blank\n'),
],
),
('key va\\\n lue\n', [KeyValue('key', 'value', 'key va\\\n lue\n')]),
('key va\\\n', [KeyValue('key', 'va', 'key va\\\n')]),
('key va\\', [KeyValue('key', 'va', 'key va\\')]),
(' \\\n\t\\\r\n\f\\\r \n', [Whitespace(' \\\n\t\\\r\n\f\\\r \n')]),
(
'key = v\\\n\ta\\\r\n\fl\\\r u\\\ne\n',
[KeyValue('key', 'value', 'key = v\\\n\ta\\\r\n\fl\\\r u\\\ne\n')],
),
])
def test_parse(s, objects):
def test_comment_source_stripped(s, ss):
assert Comment(s).source_stripped == ss
Comment('#This is a comment.\n'),
Comment('# So is this.\n'),
KeyValue('comment', 'no', 'comment: no\n'),
Comment(' ! Also a comment\n'),
],
),
(
'#Before blank\n'
'\n'
'#After blank\n'
'\n'
'before=blank\n'
'\n'
'after=blank\n',
[
Comment('#Before blank\n'),
Whitespace('\n',),
Comment('# So is this.\n'),
KeyValue('comment', 'no', 'comment: no\n'),
Comment(' ! Also a comment\n'),
],
),
(
'#Before blank\n'
'\n'
'#After blank\n'
'\n'
'before=blank\n'
'\n'
'after=blank\n',
[
Comment('#Before blank\n'),
Whitespace('\n',),
Comment('#After blank\n'),
def test_comment_value(s,v):
assert Comment(s).value == v
def test_comment_is_timestamp(c, is_t):
assert Comment(c).is_timestamp() == is_t