Debian Codegraph @

tests/test_coverup_116.py

raw symbols SCIP
1 # file scalene/scalene_utility.py:128-172
2 # lines [131, 133, 134, 135, 136, 137, 141, 143, 144, 145, 146, 147, 148, 152, 153, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 168, 169, 170, 171, 172]
3 # branches []
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 # Create a temporary profile file with some content
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 # Call the function to generate HTML
29 generate_html(profile_fname, output_fname)
30
31 # Check if the output file was created and has content
32 assert os.path.exists(output_fname)
33 with open(output_fname, "r") as f:
34 content = f.read()
35 assert content # The file should not be empty
36
37 # Check if the output file contains the profile content
38 assert "profile content" in content
39
40 # Clean up the created files
41 os.remove(profile_fname)
42 os.remove(output_fname)