| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import os |
| 6 |
import pytest |
| 7 |
from scalene.scalene_utility import generate_html |
| 8 |
|
| 9 |
|
| 10 |
@pytest.fixture |
| 11 |
def cleanup_files(): |
| 12 |
created_files = [] |
| 13 |
yield created_files |
| 14 |
for file in created_files: |
| 15 |
if os.path.exists(file): |
| 16 |
os.remove(file) |
| 17 |
|
| 18 |
|
| 19 |
def test_generate_html(cleanup_files): |
| 20 |
|
| 21 |
profile_fname = "temp_profile.prof" |
| 22 |
output_fname = "temp_output.html" |
| 23 |
cleanup_files.extend([profile_fname, output_fname]) |
| 24 |
|
| 25 |
with open(profile_fname, "w") as f: |
| 26 |
f.write("profile content") |
| 27 |
|
| 28 |
|
| 29 |
generate_html(profile_fname, output_fname) |
| 30 |
|
| 31 |
|
| 32 |
assert os.path.exists(output_fname) |
| 33 |
with open(output_fname, "r") as f: |
| 34 |
content = f.read() |
| 35 |
assert content |
| 36 |
|
| 37 |
|
| 38 |
assert "profile content" in content |
| 39 |
|
| 40 |
|
| 41 |
os.remove(profile_fname) |
| 42 |
os.remove(output_fname) |