Skip to content

Commit

Permalink
Override default logging to troubleshoot test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Oct 12, 2023
1 parent 6ba6f4a commit 964e111
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/integration/test_plugin_init.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import unittest

from os import environ
from os.path import join, dirname, isdir, isfile
from shutil import rmtree
from unittest.mock import patch

environ["OVOS_DEFAULT_LOG_NAME"] = "test"
environ["OVOS_DEFAULT_LOG_LEVEL"] = "DEBUG"


class TestPluginInit(unittest.TestCase):
@patch("ovos_utils.log.LOG")
Expand Down Expand Up @@ -37,15 +41,18 @@ def test_log_output(self, config):
LOG.init({"path": test_log_dir, "level": test_log_level})

plugin = load_tts_plugin("ovos-tts-plugin-espeakng")
self.assertEqual(LOG.base_path, test_log_dir, LOG.base_path)
self.assertEqual(LOG.level, test_log_level, LOG.level)

tts = plugin()
self.assertEqual(LOG.base_path, test_log_dir)
self.assertEqual(LOG.level, test_log_level)
self.assertTrue(isdir(test_log_dir))
self.assertEqual(LOG.base_path, test_log_dir, LOG.base_path)
self.assertEqual(LOG.level, test_log_level, LOG.level)
self.assertTrue(isdir(test_log_dir), test_log_dir)
self.assertTrue(isfile(join(test_log_dir, "ovos.log")))
with open(join(test_log_dir, "ovos.log"), 'r') as f:
logs = f.read()
self.assertIn("Amplitude: ", logs)
self.assertIn(f"{tts.config}", logs)

# Cleanup
rmtree(test_log_dir)
rmtree(test_log_dir)

0 comments on commit 964e111

Please sign in to comment.