AstraLuma / gpotato

a PEP 3156 event loop based on GLib
2 stars 0 forks source link

Test mocking logger fail #3

Open AstraLuma opened 9 years ago

AstraLuma commented 9 years ago

Some kind of problem with logging and mocking:

FAIL: test_accept_connection_exception (test_base_events.BaseEventLoopWithSelectorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/mock.py", line 1136, in patched
    return func(*args, **keywargs)
  File "/home/astronouth7303/code/gpotato/tests/test_base_events.py", line 695, in test_accept_connection_exception
    self.assertTrue(m_log.exception.called)  # FIXME
AssertionError: False is not true
AstraLuma commented 9 years ago
FAIL: test_callback_with_exception (test_events.HandleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/mock.py", line 1136, in patched
    return func(*args, **keywargs)
  File "/home/astronouth7303/code/gpotato/tests/test_events.py", line 1705, in test_callback_with_exception
    self.assertTrue(log.exception.called)
AssertionError: False is not true
AstraLuma commented 9 years ago
FAIL: test_tb_logger_exception_unretrieved (test_futures.FutureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/mock.py", line 1136, in patched
    return func(*args, **keywargs)
  File "/home/astronouth7303/code/gpotato/tests/test_futures.py", line 205, in test_tb_logger_exception_unretrieved
    self.assertTrue(m_log.error.called)
AssertionError: False is not true
AstraLuma commented 9 years ago
FAIL: test_create_server (test_proactor_events.BaseProactorEventLoopTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/mock.py", line 1136, in patched
    return func(*args, **keywargs)
  File "/home/astronouth7303/code/gpotato/tests/test_proactor_events.py", line 461, in test_create_server
    self.assertTrue(m_log.exception.called)
AssertionError: False is not true
AstraLuma commented 9 years ago
FAIL: test_fatal_error (test_proactor_events.ProactorSocketTransportTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.4/unittest/mock.py", line 1136, in patched
    return func(*args, **keywargs)
  File "/home/astronouth7303/code/gpotato/tests/test_proactor_events.py", line 223, in test_fatal_error
    self.assertTrue(m_logging.exception.called)
AssertionError: False is not true
AstraLuma commented 9 years ago

The solution here is to refactor the tests to leverage the logging framework instead of fighting it. That is, hook into the logging framework and see if a message of level EXCEPTION has been logged.