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('#'):
|
||||
continue
|
||||
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()
|
||||
# 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)
|
||||
|
@ -26,6 +26,7 @@ import re
|
||||
import sys
|
||||
import socket
|
||||
import os.path
|
||||
import functools
|
||||
|
||||
import pytest
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
@ -89,6 +90,7 @@ class Request(testprocess.Line):
|
||||
return NotImplemented
|
||||
|
||||
|
||||
@functools.total_ordering
|
||||
class ExpectedRequest:
|
||||
|
||||
"""Class to compare expected requests easily."""
|
||||
@ -97,6 +99,11 @@ class ExpectedRequest:
|
||||
self.verb = verb
|
||||
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):
|
||||
if isinstance(other, (Request, ExpectedRequest)):
|
||||
return (self.verb == other.verb and
|
||||
@ -104,6 +111,12 @@ class ExpectedRequest:
|
||||
else:
|
||||
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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user