Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
494 B
1
Indexable
Never
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
Leave a Comment