Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Stub out a test class for each request. #73

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions tests/helpers/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class MessageProtocol(namedtuple('Protocol', 'parse encode iter')):
iterator should stop.
"""

def parse_each(self, messages):
"""Yield the parsed version of each message."""
for msg in messages:
yield self.parse(msg)


class Started(object):
"""A simple wrapper around a started message protocol daemon."""
Expand Down Expand Up @@ -81,15 +86,21 @@ def __init__(self, connect, protocol, handler):
self._server = None
self._listener = None

@property
def protocol(self):
return self._protocol

@property
def received(self):
"""All the messages received thus far."""
#parsed = self._protocol.parse_each(self._received)
#return list(parsed)
return list(self._received)

@property
def failures(self):
"""All send/recv failures thus far."""
return self._failures
return list(self._failures)

def start(self, host, port):
"""Start the fake daemon.
Expand Down Expand Up @@ -136,12 +147,6 @@ def reset(self, force=False):
raise RuntimeError('have pending handlers')
self._received = []

def assert_received(self, case, expected):
"""Ensure that the received messages match the expected ones."""
received = [self._protocol.parse(msg) for msg in self._received]
expected = [self._protocol.parse(msg) for msg in expected]
case.assertEqual(received, expected)

# internal methods

def _start(self, host=None):
Expand Down
1 change: 1 addition & 0 deletions tests/helpers/pydevd/_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class FakePyDevd(protocol.Daemon):

STARTED = Started

PROTOCOL = PROTOCOL
VERSION = '1.1.1'

@classmethod
Expand Down
4 changes: 4 additions & 0 deletions tests/helpers/vsc/_fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class FakeVSC(protocol.Daemon):
protocol itself.
""" # noqa

STARTED = Started

PROTOCOL = PROTOCOL

def __init__(self, start_adapter, handler=None):
super(FakeVSC, self).__init__(socket.connect, PROTOCOL, handler)

Expand Down
Loading