diff --git a/tests/integration/test_mhtml_e2e.py b/tests/integration/test_mhtml_e2e.py
index fedf6bd69..4fa0654c6 100644
--- a/tests/integration/test_mhtml_e2e.py
+++ b/tests/integration/test_mhtml_e2e.py
@@ -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)
diff --git a/tests/integration/webserver.py b/tests/integration/webserver.py
index 5932e9042..fa8ba0a88 100644
--- a/tests/integration/webserver.py
+++ b/tests/integration/webserver.py
@@ -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):