Skip to content

Commit

Permalink
hatch fmt (#204)
Browse files Browse the repository at this point in the history
Signed-off-by: Inada Naoki <songofacandy@gmail.com>
  • Loading branch information
methane authored Feb 29, 2024
1 parent c8d7dde commit cfed7c5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
3 changes: 1 addition & 2 deletions fluent/asynchandler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from fluent import asyncsender
from fluent import handler
from fluent import asyncsender, handler


class FluentHandler(handler.FluentHandler):
Expand Down
2 changes: 1 addition & 1 deletion fluent/asyncsender.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import threading
from queue import Queue, Full, Empty
from queue import Empty, Full, Queue

from fluent import sender
from fluent.sender import EventTime
Expand Down
2 changes: 1 addition & 1 deletion fluent/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(
self._formatter = self._format_by_dict
self.usesTime = self._format_by_dict_uses_time
else:
if hasattr(fmt, "__call__"):
if callable(fmt):
self._formatter = fmt
self.usesTime = fmt.usesTime
else:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_asyncsender.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import socket
import unittest

import msgpack
Expand Down Expand Up @@ -122,13 +121,13 @@ def test_no_last_error_on_successful_emit(self):

def test_last_error_property(self):
EXCEPTION_MSG = "custom exception for testing last_error property"
self._sender.last_error = socket.error(EXCEPTION_MSG)
self._sender.last_error = OSError(EXCEPTION_MSG)

self.assertEqual(self._sender.last_error.args[0], EXCEPTION_MSG)

def test_clear_last_error(self):
EXCEPTION_MSG = "custom exception for testing clear_last_error"
self._sender.last_error = socket.error(EXCEPTION_MSG)
self._sender.last_error = OSError(EXCEPTION_MSG)
self._sender.clear_last_error()

self.assertEqual(self._sender.last_error, None)
Expand All @@ -141,7 +140,7 @@ def test_connect_exception_during_sender_init(self, mock_socket):
# Make the socket.socket().connect() call raise a custom exception
mock_connect = mock_socket.socket.return_value.connect
EXCEPTION_MSG = "a sender init socket connect() exception"
mock_connect.side_effect = socket.error(EXCEPTION_MSG)
mock_connect.side_effect = OSError(EXCEPTION_MSG)

self.assertEqual(self._sender.last_error.args[0], EXCEPTION_MSG)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_logging_with_timestamp(self):
# XXX: This tests succeeds even if the fluentd connection failed

# send event with tag app.follow, with timestamp
event.Event("follow", {"from": "userA", "to": "userB"}, time=int(0))
event.Event("follow", {"from": "userA", "to": "userB"}, time=0)

def test_no_last_error_on_successful_event(self):
global_sender = sender.get_global_sender()
Expand Down
13 changes: 6 additions & 7 deletions tests/test_sender.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import errno
import socket
import sys
import unittest
from shutil import rmtree
Expand Down Expand Up @@ -121,13 +120,13 @@ def test_no_last_error_on_successful_emit(self):

def test_last_error_property(self):
EXCEPTION_MSG = "custom exception for testing last_error property"
self._sender.last_error = socket.error(EXCEPTION_MSG)
self._sender.last_error = OSError(EXCEPTION_MSG)

self.assertEqual(self._sender.last_error.args[0], EXCEPTION_MSG)

def test_clear_last_error(self):
EXCEPTION_MSG = "custom exception for testing clear_last_error"
self._sender.last_error = socket.error(EXCEPTION_MSG)
self._sender.last_error = OSError(EXCEPTION_MSG)
self._sender.clear_last_error()

self.assertEqual(self._sender.last_error, None)
Expand Down Expand Up @@ -225,12 +224,12 @@ def __init__(self):
self.send_side_effects = [3, 0, 9]
self.send_idx = 0
self.recv_side_effects = [
socket.error(errno.EWOULDBLOCK, "Blah"),
OSError(errno.EWOULDBLOCK, "Blah"),
b"this data is going to be ignored",
b"",
socket.error(errno.EWOULDBLOCK, "Blah"),
socket.error(errno.EWOULDBLOCK, "Blah"),
socket.error(errno.EACCES, "This error will never happen"),
OSError(errno.EWOULDBLOCK, "Blah"),
OSError(errno.EWOULDBLOCK, "Blah"),
OSError(errno.EACCES, "This error will never happen"),
]
self.recv_idx = 0

Expand Down

0 comments on commit cfed7c5

Please sign in to comment.