From 5856b24d20f1c9e7d103564844e5c411d7b8979d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 14 Jan 2016 22:34:26 +0100 Subject: [PATCH] bdd: Compare HTTP status to a whitelist. 401 (authorization required) is not < 400, and it makes more sense to be strict here anyways. --- tests/integration/webserver.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/integration/webserver.py b/tests/integration/webserver.py index 6e1daa194..b33179fdc 100644 --- a/tests/integration/webserver.py +++ b/tests/integration/webserver.py @@ -24,6 +24,7 @@ import sys import json import socket import os.path +import http.client import pytest from PyQt5.QtCore import pyqtSignal @@ -59,9 +60,14 @@ class Request(testprocess.Line): missing_paths = ['/favicon.ico', '/does-not-exist'] if self.path in missing_paths: - assert self.status == 404 + assert self.status == http.client.NOT_FOUND # 404 else: - assert self.status < 400 + expected_http_statuses = [ + http.client.OK, # 200 + http.client.FOUND, # 302 + http.client.UNAUTHORIZED # 401 + ] + assert self.status in expected_http_statuses def __eq__(self, other): return NotImplemented