diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/mozharness/test/test_base_log.py | |
parent | Initial commit. (diff) | |
download | thunderbird-59f4b6b6d49b15c5a468f3fe34f3cfa4dd956ce2.tar.xz thunderbird-59f4b6b6d49b15c5a468f3fe34f3cfa4dd956ce2.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/mozharness/test/test_base_log.py')
-rw-r--r-- | testing/mozharness/test/test_base_log.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/mozharness/test/test_base_log.py b/testing/mozharness/test/test_base_log.py new file mode 100644 index 0000000000..769cb1e390 --- /dev/null +++ b/testing/mozharness/test/test_base_log.py @@ -0,0 +1,43 @@ +import os +import shutil +import unittest + +import mozharness.base.log as log + +tmp_dir = "test_log_dir" +log_name = "test" + + +def clean_log_dir(): + if os.path.exists(tmp_dir): + shutil.rmtree(tmp_dir) + + +def get_log_file_path(level=None): + if level: + return os.path.join(tmp_dir, "%s_%s.log" % (log_name, level)) + return os.path.join(tmp_dir, "%s.log" % log_name) + + +class TestLog(unittest.TestCase): + def setUp(self): + clean_log_dir() + + def tearDown(self): + clean_log_dir() + + def test_log_dir(self): + fh = open(tmp_dir, "w") + fh.write("foo") + fh.close() + l = log.SimpleFileLogger( + log_dir=tmp_dir, log_name=log_name, log_to_console=False + ) + self.assertTrue(os.path.exists(tmp_dir)) + l.log_message("blah") + self.assertTrue(os.path.exists(get_log_file_path())) + del l + + +if __name__ == "__main__": + unittest.main() |