Beispiel #1
0
def test_write_file_yaml(tmpdir):
    path = tmpdir.mkdir('sub').join('outfile.yaml')
    pathname = abspath(path)
    file_io.write_file(pathname, VALUE)
    assert len(tmpdir.listdir()) == 1
    assert path.read() == EXAMPLE_YAML
    tmpdir.remove()
Beispiel #2
0
def test_write_file_yaml_gz(tmpdir):
    path = tmpdir.mkdir('sub').join('outfile.yaml.gz')
    pathname = abspath(path)
    file_io.write_file(pathname, VALUE)
    assert len(tmpdir.listdir()) == 1
    with open(pathname, 'rb') as fh:
        assert binascii.hexlify(fh.read(2)) == b'1f8b'
    tmpdir.remove()
Beispiel #3
0
def test_write_file_plain(tmpdir):
    path = tmpdir.mkdir('sub').join('outfile.txt')
    pathname = abspath(path)
    example_string = 'file content\n'
    file_io.write_file(pathname, example_string)
    assert len(tmpdir.listdir()) == 1
    assert path.read() == example_string
    tmpdir.remove()
Beispiel #4
0
def test_write_file_invalid_path():
    example_string = 'file content\n'
    assert file_io.write_file('path/does/not/exist', example_string) is False
    assert file_io.write_file('path/does/not/exist.gz', example_string) is False