-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Dear Giorgio,
Introduction
Our background is that we are currently building a test suite based on CPython/Pytest for invoking MicroPython programs, see also micropython/micropython#5786 and micropython/micropython#4955. It works pretty good so far. Thanks again for Mocket, it helped us tremendously already.
Problem
So, after successfully creating a Pytest LoRa socket mock fixture, we are now struggling creating a corresponding thing for the urequests module.
The gist is that urequests will work like that:
sock.connect(address[-1])
sock.write("%s %s HTTP/1.0\r\n" % (method, path))
sock.write("Host: %s\r\n" % host)
which makes Mocket only see the first line:
b'POST /api/data HTTP/1.0\r\n'
so that it will croak with the following exception.
Exception
> _, self.body = decode_from_bytes(data).split('\r\n\r\n', 1)
E ValueError: not enough values to unpack (expected 2, got 1)
.venv3/lib/python3.8/site-packages/mocket/mockhttp.py:23: ValueErrorReproduction
I have been able to create a repro using pytest.
https://gist.github.com/amotl/015ef6b336db55128798d7f1a9a67dea
Thoughts
I believe @sjaensch observed this within #66 already and apparently #67 didn't fix it yet.
Thanks already for looking into this!
With kind regards,
Andreas.