Skip to content

Commit 894ae53

Browse files
authored
Use www.locust.cloud host instead of bare locust.cloud in examples and tests (#3234)
1 parent 70184df commit 894ae53

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

examples/test_pytest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
# pytest/locust will discover any functions prefixed with "test_" as test cases.
77
# session and fastsession are pytest fixtures provided by Locust's pytest plugin.
8-
def test_stuff(session: HttpSession):
9-
resp = session.get("https://locust.cloud/")
8+
def test_stuff(session):
9+
resp = session.get("https://www.locust.cloud/")
1010

1111
# Bad HTTP status codes in the response dont automatically raise an exception,
1212
# so if that is what you want, you need to call:
@@ -17,7 +17,7 @@ def test_stuff(session: HttpSession):
1717
# Just like with Locust, you can set a base URL using --host/-H when using pytest.
1818
# Or you can set a default:
1919
if not session.base_url:
20-
session.base_url = "https://locust.cloud"
20+
session.base_url = "https://www.locust.cloud"
2121

2222
# catch_response works just like in regular locustfiles
2323
with session.get("/", catch_response=True) as resp:

locust/test/test_load_locustfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,16 @@ def test_profile_flag(self):
250250
def test_pytest_user(self):
251251
content = """
252252
def test_thing(session):
253-
session.get("https://locust.cloud/")
254-
resp = session.get("https://locust.cloud/doesnt_exist")
253+
session.get("https://www.locust.cloud/")
254+
resp = session.get("https://www.locust.cloud/doesnt_exist")
255255
# the next line will raise a requests.Exception, which will be caught and ignored by Locust, but
256256
# it prevents the test from continuing, and is very useful for failing the test case
257257
resp.raise_for_status()
258-
session.get("https://locust.cloud/should_never_run")
258+
session.get("https://www.locust.cloud/should_never_run")
259259
260260
261261
def test_other_thing(fastsession):
262-
fastsession.get("https://locust.cloud/")
262+
fastsession.get("https://www.locust.cloud/")
263263
"""
264264
with mock_locustfile(content=content) as mocked:
265265
user_classes = main.load_locustfile_pytest(mocked.file_path)

locust/test/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ def test_xxcrash(session):
11661166
os.remove(output_filepath)
11671167
with mock_locustfile(content=LOCUSTFILE_CONTENT) as mocked:
11681168
with TestProcess(
1169-
f"locust -f {mocked.file_path} -H https://locust.cloud --headless -u 2 -r 10 -t 3 --exit-code-on-error 0",
1169+
f"locust -f {mocked.file_path} -H https://www.locust.cloud --headless -u 2 -r 10 -t 3 --exit-code-on-error 0",
11701170
) as tp:
11711171
tp.expect(
11721172
"/ 2 0(0.00%)",

locust/test/test_pytest_locustfile.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,48 @@
1313

1414

1515
def test_regular(session: HttpSession):
16-
session.get("https://locust.cloud/")
16+
session.get("https://www.locust.cloud/")
1717

1818

1919
def test_fasthttp(fastsession: FastHttpSession):
20-
fastsession.get("https://locust.cloud/")
20+
fastsession.get("https://www.locust.cloud/")
2121

2222

2323
@pytest.mark.xfail(strict=True)
2424
def test_failure(session: HttpSession):
25-
session.get("https://locust.cloud/")
26-
resp = session.get("https://locust.cloud/doesnt_exist")
25+
session.get("https://www.locust.cloud/")
26+
resp = session.get("https://www.locust.cloud/doesnt_exist")
2727
# the next line will raise a requests.Exception, which will be caught and ignored by Locust.
2828
# It still prevents the test from going to the next statement, and is useful for failing the test case when run as pytest
2929
resp.raise_for_status()
30-
session.get("https://locust.cloud/will_never_run")
30+
session.get("https://www.locust.cloud/will_never_run")
3131

3232

3333
def test_catch_response(session: HttpSession):
34-
with session.get("https://locust.cloud/", catch_response=True) as resp:
34+
with session.get("https://www.locust.cloud/", catch_response=True) as resp:
3535
if not resp.text or not "asdfasdf" in resp.text:
3636
resp.failure("important text was missing in response")
3737
pytest.raises(CatchResponseError, resp.raise_for_status)
3838

3939

4040
def test_fasthttp_catch_response(fastsession: FastHttpSession):
41-
with fastsession.get("https://locust.cloud/", catch_response=True) as resp:
41+
with fastsession.get("https://www.locust.cloud/", catch_response=True) as resp:
4242
if not resp.text or not "asdfasdf" in resp.text:
4343
resp.failure("important text was missing in response")
4444
pytest.raises(CatchResponseError, resp.raise_for_status)
4545

4646

4747
@pytest.mark.xfail(strict=True)
4848
def test_fasthttp_failure(fastsession: FastHttpSession):
49-
fastsession.get("https://locust.cloud/")
50-
resp = fastsession.get("https://locust.cloud/doesnt_exist")
49+
fastsession.get("https://www.locust.cloud/")
50+
resp = fastsession.get("https://www.locust.cloud/doesnt_exist")
5151
# the next line will raise a requests.Exception, which will be caught and ignored by Locust.
5252
# It still prevents the test from going to the next statement, and is useful for failing the test case when run as pytest
5353
resp.raise_for_status()
54-
fastsession.get("https://locust.cloud/will_never_run")
54+
fastsession.get("https://www.locust.cloud/will_never_run")
55+
56+
57+
host = "https://www.locust.cloud/"
5558

5659

5760
def test_host(fastsession: FastHttpSession):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ all = [
225225
fail_fast = "pytest -x {args:locust/test/test_main.py}"
226226

227227
# Run pytest-style example locustfile in pytest
228-
test_pytest = "pytest -H https://locust.cloud examples/test_pytest.py"
228+
test_pytest = "pytest -H https://www.locust.cloud examples/test_pytest.py"
229229

230230
## CI integration testing
231231

0 commit comments

Comments
 (0)