I am getting the following pytest error:
@pytest.fixture
def mts_parser():
"""MTS parser fixture
"""
mts = exchanges.get("MTS.CASH", db_write=False, filename='bondreference_20171023.txt')
> mts.get_subparser()(mts, b'')
E TypeError: __call__() missing 1 required positional argument: 'context'
tests/unit/exchanges/mts/test_parser.py:27: TypeError
_________________________________ ERROR at setup of TestMTSParser.test_get_update_type_cancel[6-False-6-0]
In fact pytest is failing in a number of tests relating to this error:
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_update_type_add[0-0-False-0-200-False] - TypeError: __call__() miss...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_update_type_add[0-1-True-6-200-False] - TypeError: __call__() missi...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_update_type_add[0-0-False-17-200-True] - TypeError: __call__() miss...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_update_type_add[0-1-False-6-200-True] - TypeError: __call__() missi...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_update_type_add[0-0-False-18-100-True] - TypeError: __call__() miss...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_update_type_add[0-1-False-6-100-True] - TypeError: __call__() missi...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_parse_fills[True-119.2--.306] - TypeError: __call__() missing 1 require...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_parse_fills[True-5-.] - TypeError: __call__() missing 1 required positi...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_parse_fills[False-119.2--.306] - TypeError: __call__() missing 1 requir...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_parse_fills[False-5-.] - TypeError: __call__() missing 1 required posit...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_parse_orders - TypeError: __call__() missing 1 required positional argu...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_parse_orders_bad_quantity - TypeError: __call__() missing 1 required po...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_isin[ES00000123B9] - TypeError: __call__() missing 1 required posit...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_isin[DE0001135408] - TypeError: __call__() missing 1 required posit...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_isin[DE0001104719] - TypeError: __call__() missing 1 required posit...
ERROR tests/unit/exchanges/mts/test_parser.py::TestMTSParser::test_get_isin[HU0000402730] - TypeError: __call__() missing 1 required posit...
Here is the aforementioned __call__ function that is causing the failed test (it is worth noting that I recently added context below:
class Subparser:
def __call__(self, obj, data, context):
self.parser = obj
self.logger = obj.logger
self.parse_er_data(data, context)
I am trying to understand what is causing this error- is it because the different functions that are calling on dunder call are missing this extra context argument? Or have I added context wrongly to the dunder call function above?
Do let me know if more information is required!
The aforementioned context comes from the following:
class PacketContext:
def __init__(self, capture_tstamp=None):
self.capture_tstamp = capture_tstamp
class SubparserMixin:
def __init__(self):
self.context = PacketContext()
self.subparsers = {}
def on_packet(self, packet):
self.context.capture_tstamp = packet.capture_timestamp
self.parse_er_data(packet.payload, self.context)