Exemplo n.º 1
0
def test_open_file_ignore_no_encoding(runner):
    with runner.isolated_filesystem():
        with open("test.bin", "wb") as f:
            f.write(os.urandom(16))

        with click.open_file("test.bin", errors="ignore") as f:
            f.read()
Exemplo n.º 2
0
def test_open_file_ignore_invalid_utf8(runner):
    with runner.isolated_filesystem():
        with open("test.txt", "wb") as f:
            f.write(b"\xe2\x28\xa1")

        with click.open_file("test.txt", encoding="utf8", errors="ignore") as f:
            f.read()
Exemplo n.º 3
0
def test_open_file_respects_ignore(runner):
    with runner.isolated_filesystem():
        with open("test.txt", "w") as f:
            f.write("Hello world!")

        with click.open_file("test.txt", encoding="utf8", errors="ignore") as f:
            assert f.errors == "ignore"
Exemplo n.º 4
0
 def cli(filename):
     with click.open_file(filename) as f:
         click.echo(f.read())
     click.echo('meep')
Exemplo n.º 5
0
 def cli(filename):
     click.open_file(filename, "w", atomic=True).close()
Exemplo n.º 6
0
 def cli(filename):
     with click.open_file(filename, errors="ignore") as f:
         click.echo(f.read())