Skip to content

Commit 80067ed

Browse files
committed
fix: Use monkeypatch where possible
1 parent 78d17d1 commit 80067ed

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

tests/test_client.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -92,66 +92,66 @@ def test_proxy_none_noenv(monkeypatch):
9292

9393

9494
def test_proxy_none_httpenv_select(monkeypatch):
95-
os.environ["HTTP_PROXY"] = "http://localhost/123"
95+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
9696
client = Client("http://foo@sentry.io/123")
9797
assert client.transport._pool.proxy.scheme == "http"
9898

9999

100100
def test_proxy_none_httpsenv_select(monkeypatch):
101-
os.environ["HTTPS_PROXY"] = "https://localhost/123"
101+
monkeypatch.setenv("HTTPS_PROXY", "https://localhost/123")
102102
client = Client("https://foo@sentry.io/123")
103103
assert client.transport._pool.proxy.scheme == "https"
104104

105105

106106
def test_proxy_none_httpenv_fallback(monkeypatch):
107-
os.environ["HTTP_PROXY"] = "http://localhost/123"
107+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
108108
client = Client("https://foo@sentry.io/123")
109109
assert client.transport._pool.proxy.scheme == "http"
110110

111111

112112
def test_proxy_bothselect_bothen(monkeypatch):
113-
os.environ["HTTP_PROXY"] = "http://localhost/123"
114-
os.environ["HTTPS_PROXY"] = "https://localhost/123"
113+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
114+
monkeypatch.setenv("HTTPS_PROXY", "https://localhost/123")
115115
client = Client("https://foo@sentry.io/123", http_proxy="", https_proxy="")
116116
assert client.transport._pool.proxy is None
117117

118118

119119
def test_proxy_bothavoid_bothenv(monkeypatch):
120-
os.environ["HTTP_PROXY"] = "http://localhost/123"
121-
os.environ["HTTPS_PROXY"] = "https://localhost/123"
120+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
121+
monkeypatch.setenv("HTTPS_PROXY", "https://localhost/123")
122122
client = Client("https://foo@sentry.io/123", http_proxy=None, https_proxy=None)
123123
assert client.transport._pool.proxy.scheme == "https"
124124

125125

126126
def test_proxy_bothselect_httpenv(monkeypatch):
127-
os.environ["HTTP_PROXY"] = "http://localhost/123"
127+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
128128
client = Client("https://foo@sentry.io/123", http_proxy=None, https_proxy=None)
129129
assert client.transport._pool.proxy.scheme == "http"
130130

131131

132132
def test_proxy_httpselect_bothenv(monkeypatch):
133-
os.environ["HTTP_PROXY"] = "http://localhost/123"
134-
os.environ["HTTPS_PROXY"] = "https://localhost/123"
133+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
134+
monkeypatch.setenv("HTTPS_PROXY", "https://localhost/123")
135135
client = Client("https://foo@sentry.io/123", http_proxy=None, https_proxy="")
136136
assert client.transport._pool.proxy.scheme == "http"
137137

138138

139139
def test_proxy_httpsselect_bothenv(monkeypatch):
140-
os.environ["HTTP_PROXY"] = "http://localhost/123"
141-
os.environ["HTTPS_PROXY"] = "https://localhost/123"
140+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
141+
monkeypatch.setenv("HTTPS_PROXY", "https://localhost/123")
142142
client = Client("https://foo@sentry.io/123", http_proxy="", https_proxy=None)
143143
assert client.transport._pool.proxy.scheme == "https"
144144

145145

146146
def test_proxy_httpselect_httpsenv(monkeypatch):
147-
os.environ["HTTPS_PROXY"] = "https://localhost/123"
147+
monkeypatch.setenv("HTTPS_PROXY", "https://localhost/123")
148148
client = Client("https://foo@sentry.io/123", http_proxy=None, https_proxy="")
149149
assert client.transport._pool.proxy is None
150150

151151

152152
def test_proxy_httpsselect_bothenv_http(monkeypatch):
153-
os.environ["HTTP_PROXY"] = "http://localhost/123"
154-
os.environ["HTTPS_PROXY"] = "https://localhost/123"
153+
monkeypatch.setenv("HTTP_PROXY", "http://localhost/123")
154+
monkeypatch.setenv("HTTPS_PROXY", "https://localhost/123")
155155
client = Client("http://foo@sentry.io/123", http_proxy=None, https_proxy=None)
156156
assert client.transport._pool.proxy.scheme == "http"
157157

0 commit comments

Comments
 (0)