Fix mhtml tests
This commit is contained in:
parent
3438a45b19
commit
4060fd5e90
@ -97,7 +97,10 @@ def test_mhtml(test_name, download_dir, quteproc, httpbin):
|
|||||||
if line.startswith('#'):
|
if line.startswith('#'):
|
||||||
continue
|
continue
|
||||||
path = '/{}/{}'.format(test_path, line.strip())
|
path = '/{}/{}'.format(test_path, line.strip())
|
||||||
expected_requests.append(httpbin.Request('GET', path))
|
expected_requests.append(httpbin.ExpectedRequest('GET', path))
|
||||||
|
|
||||||
actual_requests = httpbin.get_requests()
|
actual_requests = httpbin.get_requests()
|
||||||
|
# Requests are unorderable, we need to convert to ExpectedRequests
|
||||||
|
actual_requests = map(httpbin.ExpectedRequest.from_request,
|
||||||
|
actual_requests)
|
||||||
assert sorted(actual_requests) == sorted(expected_requests)
|
assert sorted(actual_requests) == sorted(expected_requests)
|
||||||
|
@ -26,6 +26,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
import os.path
|
import os.path
|
||||||
|
import functools
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from PyQt5.QtCore import pyqtSignal
|
from PyQt5.QtCore import pyqtSignal
|
||||||
@ -89,6 +90,7 @@ class Request(testprocess.Line):
|
|||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
|
@functools.total_ordering
|
||||||
class ExpectedRequest:
|
class ExpectedRequest:
|
||||||
|
|
||||||
"""Class to compare expected requests easily."""
|
"""Class to compare expected requests easily."""
|
||||||
@ -97,6 +99,11 @@ class ExpectedRequest:
|
|||||||
self.verb = verb
|
self.verb = verb
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_request(cls, request):
|
||||||
|
"""Create an ExpectedRequest from a Request."""
|
||||||
|
return cls(request.verb, request.path)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, (Request, ExpectedRequest)):
|
if isinstance(other, (Request, ExpectedRequest)):
|
||||||
return (self.verb == other.verb and
|
return (self.verb == other.verb and
|
||||||
@ -104,6 +111,12 @@ class ExpectedRequest:
|
|||||||
else:
|
else:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
if isinstance(other, (Request, ExpectedRequest)):
|
||||||
|
return (self.verb, self.path) < (other.verb, other.path)
|
||||||
|
else:
|
||||||
|
return NotImplemented
|
||||||
|
|
||||||
|
|
||||||
class HTTPBin(testprocess.Process):
|
class HTTPBin(testprocess.Process):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user