Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cmd_format_file():
runner = CliRunner()
with runner.isolated_filesystem():
with open('test.properties', 'wb') as fp:
fp.write(INPUT)
r = CliRunner().invoke(javaproperties, ['format', 'test.properties'])
assert r.exit_code == 0
assert r.output_bytes == OUTPUT
def test_cmd_get_utf8_not_exists():
r = CliRunner().invoke(javaproperties, [
'get', '-', b'x\xC3\xB0'
], input=INPUT)
assert r.exit_code == 1
assert r.output_bytes == b'javaproperties: x\xC3\xB0: key not found\n'
def test_cmd_set_escaped_not_exists():
r = CliRunner().invoke(javaproperties, [
'set', '--preserve-timestamp', '--escaped', '-', 'x\\u00F0', '\\u00A1new!'
], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'''\
foo: bar
def test_cmd_delete_exists():
r = CliRunner().invoke(javaproperties, [
'delete', '--preserve-timestamp', '-', 'key'
], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'''\
foo: bar
def test_cmd_delete_utf8():
r = CliRunner().invoke(javaproperties, [
'delete', '--preserve-timestamp', '-', b'e\xC3\xB0' # 'e\u00f0'
], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'''\
foo: bar
def test_cmd_set_exists():
r = CliRunner().invoke(javaproperties, [
'set', '--preserve-timestamp', '-', 'key', 'other value'
], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'''\
foo: bar
def test_cmd_select_bmp_output():
r = CliRunner().invoke(javaproperties, ['select', '-', 'bmp'], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'''\
#Mon Nov 07 15:29:40 EST 2016
def test_cmd_select_exists():
r = CliRunner().invoke(javaproperties, ['select', '-', 'key'], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'#Mon Nov 07 15:29:40 EST 2016\nkey=value\n'
def test_cmd_format_stdin():
r = CliRunner().invoke(javaproperties, ['format'], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == OUTPUT
def test_cmd_get_exists():
r = CliRunner().invoke(javaproperties, ['get', '-', 'key'], input=INPUT)
assert r.exit_code == 0
assert r.output_bytes == b'value\n'