1
1
# encoding=utf-8
2
2
import logging
3
+ import os
3
4
import platform
4
5
5
6
import pytest
19
20
logger = logging .getLogger (__name__ )
20
21
21
22
INTERNET_CONNECTED = internet_connection ()
23
+ LOCAL = os .getenv ("GITHUB_ACTIONS" ) != "true"
24
+ LINUX = platform .system () == "Linux"
25
+ HTTPBIN_CONTAINERISED = LINUX or LOCAL
22
26
23
27
24
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
28
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
25
29
def test_proxy (mock_server , httpbin ):
26
30
imposter = Imposter (Stub (responses = Proxy (to = httpbin )))
27
31
@@ -34,7 +38,7 @@ def test_proxy(mock_server, httpbin):
34
38
assert_that (imposter , had_request ().with_path ("/" ).and_method ("GET" ))
35
39
36
40
37
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
41
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
38
42
def test_stub_with_proxy_fallback (mock_server , httpbin ):
39
43
imposter = Imposter (
40
44
stubs = [
@@ -54,7 +58,7 @@ def test_stub_with_proxy_fallback(mock_server, httpbin):
54
58
assert_that (imposter , had_request ().with_path ("/" ).and_method ("GET" ))
55
59
56
60
57
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
61
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
58
62
def test_proxy_playback (mock_server , httpbin ):
59
63
proxy_imposter = Imposter (Stub (responses = Proxy (to = httpbin , mode = Proxy .Mode .ONCE )))
60
64
@@ -78,7 +82,7 @@ def test_proxy_playback(mock_server, httpbin):
78
82
)
79
83
80
84
81
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
85
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
82
86
def test_proxy_uses_path_predicate_generator (mock_server , httpbin ):
83
87
proxy_imposter = Imposter (
84
88
Stub (
@@ -110,7 +114,7 @@ def test_proxy_uses_path_predicate_generator(mock_server, httpbin):
110
114
assert_that (response , is_response ().with_status_code (200 ))
111
115
112
116
113
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
117
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
114
118
def test_proxy_uses_query_predicate_generator (mock_server , httpbin ):
115
119
proxy_imposter = Imposter (
116
120
Stub (
@@ -150,7 +154,7 @@ def test_proxy_uses_query_predicate_generator(mock_server, httpbin):
150
154
)
151
155
152
156
153
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
157
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
154
158
def test_proxy_uses_query_predicate_generator_with_key (mock_server , httpbin ):
155
159
proxy_imposter = Imposter (
156
160
Stub (
@@ -200,7 +204,7 @@ def test_proxy_uses_query_predicate_generator_with_key(mock_server, httpbin):
200
204
)
201
205
202
206
203
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
207
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
204
208
def test_proxy_without_stub (mock_server , httpbin ):
205
209
imposter = Imposter (Stub (responses = Proxy (to = httpbin )))
206
210
@@ -212,7 +216,7 @@ def test_proxy_without_stub(mock_server, httpbin):
212
216
)
213
217
214
218
215
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
219
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
216
220
def test_proxy_delay (mock_server ):
217
221
target_imposter = Imposter (Stub (Predicate (path = "/test" )))
218
222
with mock_server (target_imposter ) as server :
@@ -225,7 +229,7 @@ def test_proxy_delay(mock_server):
225
229
assert_that (timer .elapsed , between (0.1 , 0.5 ))
226
230
227
231
228
- @pytest .mark .xfail (platform . system () == "Windows" , reason = "Public httpbin horribly flaky." )
232
+ @pytest .mark .xfail (not HTTPBIN_CONTAINERISED , reason = "Public httpbin horribly flaky." )
229
233
def test_inject_headers (mock_server ):
230
234
target_imposter = Imposter (Stub (Predicate (path = "/test" )))
231
235
with mock_server (target_imposter ) as server :
0 commit comments