diff --git a/tests/mockserver.py b/tests/mockserver.py index 77ecdd3..f1462a1 100644 --- a/tests/mockserver.py +++ b/tests/mockserver.py @@ -92,6 +92,3 @@ def close(self): pass self.join() - - def __del__(self): - self.close() diff --git a/tests/test_asynchandler.py b/tests/test_asynchandler.py index e88a041..859f36d 100644 --- a/tests/test_asynchandler.py +++ b/tests/test_asynchandler.py @@ -25,9 +25,11 @@ def setUp(self): super(TestHandler, self).setUp() self._server = mockserver.MockRecvServer('localhost') self._port = self._server.port + logging.getLogger().setLevel(logging.INFO) def tearDown(self): self._server.close() + self._server = None def get_handler_class(self): # return fluent.handler.FluentHandler @@ -40,7 +42,6 @@ def test_simple(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -63,7 +64,6 @@ def test_custom_fmt(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -86,7 +86,6 @@ def test_custom_fmt_with_format_style(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -109,7 +108,6 @@ def test_custom_fmt_with_template_style(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -131,7 +129,6 @@ def test_custom_field_raise_exception(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -147,7 +144,6 @@ def test_custom_field_raise_exception(self): def test_custom_field_fill_missing_fmt_key_is_true(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -172,7 +168,6 @@ def test_json_encoded_message(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -186,7 +181,6 @@ def test_unstructured_message(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -200,7 +194,6 @@ def test_unstructured_formatted_message(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -214,7 +207,6 @@ def test_number_string_simple_message(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -227,7 +219,6 @@ def test_non_string_simple_message(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -240,7 +231,6 @@ def test_non_string_dict_message(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -254,7 +244,6 @@ def test_exception_message(self): handler = self.get_handler_class()('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -297,7 +286,6 @@ def test_simple(self): self.assertEqual(handler.sender.queue_circular, True) self.assertEqual(handler.sender.queue_maxsize, self.Q_SIZE) - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -359,7 +347,6 @@ def custom_full_queue(): self.assertEqual(handler.sender.queue_circular, True) self.assertEqual(handler.sender.queue_maxsize, self.Q_SIZE) - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) diff --git a/tests/test_event.py b/tests/test_event.py index d341616..21e93e4 100644 --- a/tests/test_event.py +++ b/tests/test_event.py @@ -6,7 +6,8 @@ from tests import mockserver -class TestException(BaseException): pass +class TestException(BaseException): + __test__ = False class TestEvent(unittest.TestCase): diff --git a/tests/test_handler.py b/tests/test_handler.py index 45fea86..a7cdd51 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -13,9 +13,11 @@ def setUp(self): super(TestHandler, self).setUp() self._server = mockserver.MockRecvServer('localhost') self._port = self._server.port + logging.getLogger().setLevel(logging.INFO) def tearDown(self): self._server.close() + self._server = None def get_data(self): return self._server.get_received() @@ -24,7 +26,6 @@ def test_simple(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -50,7 +51,6 @@ def test_custom_fmt(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -73,7 +73,6 @@ def test_exclude_attrs(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(exclude_attrs=[]) @@ -91,7 +90,6 @@ def test_exclude_attrs_with_exclusion(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(exclude_attrs=["funcName"]) @@ -109,7 +107,6 @@ def test_exclude_attrs_with_extra(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(exclude_attrs=[]) @@ -138,7 +135,6 @@ def formatter(record): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt=formatter) @@ -157,7 +153,6 @@ def test_custom_fmt_with_format_style(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -181,7 +176,6 @@ def test_custom_fmt_with_template_style(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -204,7 +198,6 @@ def test_custom_field_raise_exception(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -223,7 +216,6 @@ def test_custom_field_fill_missing_fmt_key_is_true(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter( fluent.handler.FluentRecordFormatter(fmt={ @@ -248,7 +240,6 @@ def test_json_encoded_message(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -265,7 +256,6 @@ def test_json_encoded_message_without_json(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter(format_json=False)) log.addHandler(handler) @@ -282,7 +272,6 @@ def test_unstructured_message(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -297,7 +286,6 @@ def test_unstructured_formatted_message(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -312,7 +300,6 @@ def test_number_string_simple_message(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -326,7 +313,6 @@ def test_non_string_simple_message(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -340,7 +326,6 @@ def test_non_string_dict_message(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) @@ -355,7 +340,6 @@ def test_exception_message(self): handler = fluent.handler.FluentHandler('app.follow', port=self._port) with handler: - logging.basicConfig(level=logging.INFO) log = logging.getLogger('fluent.test') handler.setFormatter(fluent.handler.FluentRecordFormatter()) log.addHandler(handler) diff --git a/tox.ini b/tox.ini index 6c3f032..a0e2c95 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = py27, py32, py33, py34, py35, py36, py37, py38 skip_missing_interpreters = True [testenv] -deps = nose - coverage~=4.5.4 -commands = python setup.py nosetests +deps = + pytest + msgpack +commands = pytest -v