Skip to content

Commit 6589cb8

Browse files
committed
make the timeout test un-flaky
1 parent 7392ca5 commit 6589cb8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: pypi tag mypy pytest test
1+
.PHONY: pypi tag mypy pytest pytest-pdb test
22

33
pypi:
44
rm -f dist/*
@@ -14,6 +14,9 @@ mypy:
1414
mypy --py2 --ignore-missing-imports popget
1515

1616
pytest:
17+
py.test -v -s tests/
18+
19+
pytest-pdb:
1720
py.test -v -s --ipdb tests/
1821

1922
test:

tests/test_client.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from six.moves.urllib import parse as urlparse
22

33
from flexisettings.utils import override_settings
4+
from urllib3.exceptions import ConnectTimeoutError
45
import pytest
56
import requests
67
import responses
@@ -504,13 +505,20 @@ def callback(request):
504505
assert len(responses.calls) == 1
505506

506507

507-
@override_settings(settings, CLIENT_TIMEOUT=0.000001)
508+
class TimeoutService(DummyService):
509+
510+
class Config:
511+
# (psf/requests uses this for its timeout test)
512+
base_url = 'http://10.255.255.1/'
513+
514+
515+
@override_settings(settings, CLIENT_TIMEOUT=1)
508516
def test_timeout():
509517
"""
510518
Test APIClient behaviour when the requests library timeout threshold is reached
511519
"""
512520
with pytest.raises(requests.exceptions.HTTPError) as exc_info:
513-
DummyService.thing_detail(id=777)
521+
TimeoutService.thing_detail(id=777)
514522

515523
e = exc_info.value
516524
assert e.response.status_code == 504

0 commit comments

Comments
 (0)