Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tests: Avoid "import logging" and setting root logger level in tests.

Mohit Gupta67a67fcc0235
diff --git a/zerver/tests/test_gitter_importer.py b/zerver/tests/test_gitter_importer.py
index cd99997006c..6404cf37bd0 100644
--- a/zerver/tests/test_gitter_importer.py
+++ b/zerver/tests/test_gitter_importer.py
@@ -1,4 +1,3 @@
-import logging
import os
from typing import Any
from unittest import mock
@@ -12,15 +11,13 @@ from zerver.models import Message, UserProfile, get_realm
class GitterImporter(ZulipTestCase):
- logger = logging.getLogger()
- # set logger to a higher level to suppress 'logger.INFO' outputs
- logger.setLevel(logging.WARNING)
@mock.patch('zerver.data_import.gitter.process_avatars', return_value=[])
def test_gitter_import_data_conversion(self, mock_process_avatars: mock.Mock) -> None:
output_dir = self.make_import_output_dir("gitter")
gitter_file = os.path.join(os.path.dirname(__file__), 'fixtures/gitter_data.json')
- do_convert_data(gitter_file, output_dir)
+ with self.assertLogs(level='INFO'):
+ do_convert_data(gitter_file, output_dir)
def read_file(output_file: str) -> Any:
full_path = os.path.join(output_dir, output_file)
@@ -82,7 +79,8 @@ class GitterImporter(ZulipTestCase):
def test_gitter_import_to_existing_database(self, mock_process_avatars: mock.Mock) -> None:
output_dir = self.make_import_output_dir("gitter")
gitter_file = os.path.join(os.path.dirname(__file__), 'fixtures/gitter_data.json')
- do_convert_data(gitter_file, output_dir)
+ with self.assertLogs(level="INFO"):
+ do_convert_data(gitter_file, output_dir)
with self.assertLogs(level="INFO"):
do_import_realm(output_dir, 'test-gitter-import')