Untitled

 avatar
unknown
plain_text
a year ago
494 B
4
Indexable
def test_show_details_file_exists(tmp_path, capsys):
    file = tmp_path / "test.txt"
    with open(file, "w") as f:
        f.write("Hello World!")  ## 12 bytes
    file_created = date.fromtimestamp(os.path.getctime(file))
    context = {"base_path": str(file)}
    show_details(context)
    captured = capsys.readouterr().out
    output = f"File name: test.txt\nFile size in bytes: 12\nFile type: file\nFile extension: .txt\nLast modified date: {file_created}\n"
    assert captured == output
Editor is loading...
Leave a Comment