pep8: Add compliance with rule E261 test_logging_handlers.py.

This commit is contained in:
Aditya Bansal 2017-06-04 15:07:26 +05:30
parent 4410b5889a
commit bf1e3a0125
1 changed files with 9 additions and 9 deletions

View File

@ -108,7 +108,7 @@ class AdminZulipHandlerTest(ZulipTestCase):
record = self.logger.makeRecord('name', logging.ERROR, 'function', 15, # type: ignore # https://github.com/python/typeshed/pull/1100
'message\nmoremesssage\nmore', None,
None)
record.request = captured_request # type: ignore # this field is dynamically added
record.request = captured_request # type: ignore # this field is dynamically added
report = self.run_handler(record)
self.assertIn("user_email", report)
@ -131,7 +131,7 @@ class AdminZulipHandlerTest(ZulipTestCase):
global captured_request
global captured_exc_info
record = self.logger.makeRecord('name', logging.ERROR, 'function', 15, 'message', None, captured_exc_info) # type: ignore # https://github.com/python/typeshed/pull/1100
record.request = captured_request # type: ignore # this field is dynamically added
record.request = captured_request # type: ignore # this field is dynamically added
report = self.run_handler(record)
self.assertIn("user_email", report)
@ -148,7 +148,7 @@ class AdminZulipHandlerTest(ZulipTestCase):
self.assertEqual(report["stack_trace"], "See /var/log/zulip/errors.log")
# Check anonymous user is handled correctly
record.request.user = AnonymousUser() # type: ignore # this field is dynamically added
record.request.user = AnonymousUser() # type: ignore # this field is dynamically added
report = self.run_handler(record)
self.assertIn("host", report)
self.assertIn("user_email", report)
@ -159,10 +159,10 @@ class AdminZulipHandlerTest(ZulipTestCase):
def get_host_error():
# type: () -> None
raise Exception("Get Host Failure!")
orig_get_host = record.request.get_host # type: ignore # this field is dynamically added
record.request.get_host = get_host_error # type: ignore # this field is dynamically added
orig_get_host = record.request.get_host # type: ignore # this field is dynamically added
record.request.get_host = get_host_error # type: ignore # this field is dynamically added
report = self.run_handler(record)
record.request.get_host = orig_get_host # type: ignore # this field is dynamically added
record.request.get_host = orig_get_host # type: ignore # this field is dynamically added
self.assertIn("host", report)
self.assertIn("user_email", report)
self.assertIn("message", report)
@ -171,9 +171,9 @@ class AdminZulipHandlerTest(ZulipTestCase):
# Test an exception_filter exception
with patch("zerver.logging_handlers.get_exception_reporter_filter",
return_value=15):
record.request.method = "POST" # type: ignore # this field is dynamically added
record.request.method = "POST" # type: ignore # this field is dynamically added
report = self.run_handler(record)
record.request.method = "GET" # type: ignore # this field is dynamically added
record.request.method = "GET" # type: ignore # this field is dynamically added
self.assertIn("host", report)
self.assertIn("user_email", report)
self.assertIn("message", report)
@ -199,7 +199,7 @@ class AdminZulipHandlerTest(ZulipTestCase):
self.assertEqual(report["stack_trace"], None)
# Test arbitrary exceptions from request.user
record.request.user = None # type: ignore # this field is dynamically added
record.request.user = None # type: ignore # this field is dynamically added
with patch("zerver.logging_handlers.traceback.print_exc"):
report = self.run_handler(record)
self.assertIn("host", report)