Skip to content

Commit

Permalink
Merge pull request #1350 from jamesoff/bugfix/html-tests
Browse files Browse the repository at this point in the history
Create dir for html test output
  • Loading branch information
jamesoff authored Feb 18, 2024
2 parents 2163e69 + bca41e3 commit 1bc491d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,17 @@ def test_file_bad_rotation(self):


class TestHTMLLogger(unittest.TestCase):
@staticmethod
def setUp(self) -> None:
self.html_dir = tempfile.mkdtemp()
print(f"writing html tests to {self.html_dir}")

@freeze_time("2020-04-18 12:00:00+00:00")
def _write_html(logger_options: dict = None) -> str:
def _write_html(self, logger_options: dict = None) -> str:
if logger_options is None:
logger_options = {}
with patch.object(socket, "gethostname", return_value="fake_hostname.local"):
temp_htmlfile = tempfile.mkstemp()[1]
logger_options.update({"filename": temp_htmlfile})
logger_options.update({"filename": temp_htmlfile, "folder": self.html_dir})
html_logger = HTMLLogger(logger_options)
monitor1 = MonitorNull(config_options={"gps": "52.01,1.01"})
monitor2 = MonitorFail("fail", {"gps": "52.02,1.02"})
Expand All @@ -374,6 +377,7 @@ def _write_html(logger_options: dict = None) -> str:
html_logger.save_result2("fail", monitor2)
html_logger.save_result2("disabled", monitor3)
html_logger.end_batch()
print(temp_htmlfile)
return temp_htmlfile

def _compare_files(self, test_file, golden_file):
Expand Down

0 comments on commit 1bc491d

Please sign in to comment.