Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glaslos committed Jun 25, 2023
1 parent 027a044 commit 4b5fc89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def test_pop_server(self):
try:
sock.connect(("localhost", SpamCanPOPTest.server_port))
received = sock.recv(1024)
sock.sendall("QUIT foobar" + "\n")
sock.sendall(b'QUIT foobar\n')
finally:
sock.close()
self.assert_(received == "+OK SpamCan test server ready" + "\r\n")
self.assert_(received == b'+OK SpamCan test server ready\r\n')

def test_pop_client(self):
account_config = {
Expand Down
12 changes: 6 additions & 6 deletions testing/pop_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Based on http://code.activestate.com/recipes/534131/

import SocketServer
import socketserver


class Message(object):
Expand Down Expand Up @@ -64,15 +64,15 @@ def handleQuit(data, msg):
)


class TCPHandler(SocketServer.BaseRequestHandler):
class TCPHandler(socketserver.BaseRequestHandler):
def handle(self):
self.request.sendall("+OK SpamCan test server ready\r\n")
self.request.sendall(b'+OK SpamCan test server ready\r\n')
while True:
self.data = self.request.recv(1024).strip()
if self.data:
command = self.data.split(" ", 1)[0]
command = self.data.decode().split(" ", 1)[0]
cmd = dispatch[command]
self.request.sendall(cmd(self.data, Message()) + "\r\n")
self.request.sendall(bytes(cmd(self.data, Message()), 'utf-8') + b'\r\n')
if command == "QUIT":
break
else:
Expand All @@ -83,7 +83,7 @@ def pop_server(port=0):
"""
Returns a new instance of SocketServer.TCPServer. If port == 0 a ephemeral port will be assigned.
"""
return SocketServer.TCPServer(("localhost", port), TCPHandler)
return socketserver.TCPServer(("localhost", port), TCPHandler)


if __name__ == "__main__":
Expand Down

0 comments on commit 4b5fc89

Please sign in to comment.