Skip to content

Commit 5542fac

Browse files
Makes code compatible with changes introduced to CliRunner and handling of of exit code for no_args_is_help in Click 8.2.0
1 parent e81fd46 commit 5542fac

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
python-dateutil==2.9.0.post0
2-
click==8.1.7
2+
click==8.3.0
33
docopt==0.6.2
44
importlib-metadata==8.7.0
55
packaging

tests/test_cli_django.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test_main_subcommand_without_args_prints_help():
3838
app,
3939
[],
4040
)
41-
assert result.exit_code == 0
42-
assert "Show this message and exit." in result.stdout
41+
assert result.exit_code == 2
42+
assert "Show this message and exit." in result.stderr
4343

4444

4545
def test_autoconfigure_calls_all_stuff_in_right_order(mock_django_project):

tests/test_cli_pa.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def test_main_command_without_args_prints_help():
1414
app,
1515
[],
1616
)
17-
assert result.exit_code == 0
18-
assert "This is a new experimental PythonAnywhere cli client." in result.stdout
19-
assert "Makes Django Girls tutorial projects deployment easy" in result.stdout
20-
assert "Perform some operations on files" in result.stdout
21-
assert "Manage scheduled tasks" in result.stdout
22-
assert "Perform some operations on students" in result.stdout
23-
assert "Everything for web apps: use this if you're not using" in result.stdout
24-
assert "EXPERIMENTAL: create and manage ASGI websites" in result.stdout
17+
assert result.exit_code == 2
18+
assert "This is a new experimental PythonAnywhere cli client." in result.stderr
19+
assert "Makes Django Girls tutorial projects deployment easy" in result.stderr
20+
assert "Perform some operations on files" in result.stderr
21+
assert "Manage scheduled tasks" in result.stderr
22+
assert "Perform some operations on students" in result.stderr
23+
assert "Everything for web apps: use this if you're not using" in result.stderr
24+
assert "EXPERIMENTAL: create and manage ASGI websites" in result.stderr

tests/test_cli_path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def test_main_subcommand_without_args_prints_help():
4646
app,
4747
[],
4848
)
49-
assert result.exit_code == 0
50-
assert "Show this message and exit." in result.stdout
49+
assert result.exit_code == 2
50+
assert "Show this message and exit." in result.stderr
5151

5252

5353
class TestGet:

tests/test_cli_schedule.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def test_main_subcommand_without_args_prints_help():
4545
app,
4646
[],
4747
)
48-
assert result.exit_code == 0
49-
assert "Show this message and exit." in result.stdout
48+
assert result.exit_code == 2
49+
assert "Show this message and exit." in result.stderr
5050

5151

5252
class TestSet:
@@ -78,13 +78,13 @@ def test_calls_all_stuff_in_right_order(self, mocker):
7878
def test_validates_minutes(self):
7979
result = runner.invoke(app, ["set", "-c", "echo foo", "-h", "8", "-m", "66"])
8080

81-
assert "Invalid value" in result.stdout
82-
assert "66 is not in the range 0<=x<=59" in result.stdout
81+
assert "Invalid value" in result.stderr
82+
assert "66 is not in the range 0<=x<=59" in result.stderr
8383

8484
def test_validates_hours(self):
8585
result = runner.invoke(app, ["set", "-c", "echo foo", "-h", "66", "-m", "1"])
86-
assert "Invalid value" in result.stdout
87-
assert "66 is not in the range 0<=x<=23" in result.stdout
86+
assert "Invalid value" in result.stderr
87+
assert "66 is not in the range 0<=x<=23" in result.stderr
8888

8989
def test_logs_warning_when_create_schedule_raises(self, mocker):
9090
mock_logger = mocker.patch("cli.schedule.get_logger").return_value
@@ -259,7 +259,7 @@ def test_logs_only_value_of_requested_task_spec(self, mocker, task_from_id):
259259

260260
def test_complains_when_no_id_provided(self):
261261
result = runner.invoke(app, ["get", "--command"])
262-
assert "Missing argument 'id'" in result.stdout
262+
assert "Missing argument 'id'" in result.stderr
263263

264264

265265
class TestList:
@@ -302,7 +302,7 @@ def test_warns_when_wrong_format_provided(self, mocker, task_list):
302302

303303
assert mock_tabulate.call_count == 0
304304
assert wrong_format not in tabulate_formats
305-
assert "Table format has to be one of" in result.stdout
305+
assert "Table format has to be one of" in result.stderr
306306

307307

308308
class TestUpdate:
@@ -356,15 +356,15 @@ def test_ensures_proper_hourly_params(self, mocker):
356356

357357
def test_validates_minute(self):
358358
result = runner.invoke(app, ["update", "42", "--minute", "88"])
359-
assert "88 is not in the range 0<=x<=59" in result.stdout
359+
assert "88 is not in the range 0<=x<=59" in result.stderr
360360

361361
def test_validates_hour(self):
362362
result = runner.invoke(app, ["update", "42", "--daily", "--hour", "33"])
363-
assert "33 is not in the range 0<=x<=23" in result.stdout
363+
assert "33 is not in the range 0<=x<=23" in result.stderr
364364

365365
def test_complains_when_no_id_provided(self):
366366
result = runner.invoke(app, ["update"])
367-
assert "Missing argument 'id'" in result.stdout
367+
assert "Missing argument 'id'" in result.stderr
368368

369369
def test_exits_early_when_nothing_to_update(self, mocker):
370370
mock_logger = mocker.patch("cli.schedule.get_logger").return_value

tests/test_cli_students.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def test_main_subcommand_without_args_prints_help():
2727
app,
2828
[],
2929
)
30-
assert result.exit_code == 0
31-
assert "Show this message and exit." in result.stdout
30+
assert result.exit_code == 2
31+
assert "Show this message and exit." in result.stderr
3232

3333

3434
@pytest.mark.students

tests/test_cli_webapp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def test_main_subcommand_without_args_prints_help():
4444
app,
4545
[],
4646
)
47-
assert result.exit_code == 0
48-
assert "Show this message and exit." in result.stdout
47+
assert result.exit_code == 2
48+
assert "Show this message and exit." in result.stderr
4949

5050

5151
def test_list_webapps(mocker):
@@ -240,8 +240,8 @@ def test_validates_log_number(mock_webapp):
240240
result = runner.invoke(
241241
app, ["delete-logs", "-d", "foo.bar.baz", "-t", "server", "-i", "10"]
242242
)
243-
assert "Invalid value" in result.stdout
244-
assert "log_index has to be 0 for current" in result.stdout
243+
assert "Invalid value" in result.stderr
244+
assert "log_index has to be 0 for current" in result.stderr
245245

246246

247247
def test_delete_webapp(mock_webapp, domain_name):

tests/test_cli_website.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def test_main_subcommand_without_args_prints_help():
6666
app,
6767
[],
6868
)
69-
assert result.exit_code == 0
70-
assert "Show this message and exit." in result.stdout
69+
assert result.exit_code == 2
70+
assert "Show this message and exit." in result.stderr
7171

7272

7373
def test_create_without_domain_barfs():
@@ -80,7 +80,7 @@ def test_create_without_domain_barfs():
8080
],
8181
)
8282
assert result.exit_code != 0
83-
assert "Missing option" in result.stdout
83+
assert "Missing option" in result.stderr
8484

8585

8686
def test_create_without_command_barfs():
@@ -93,7 +93,7 @@ def test_create_without_command_barfs():
9393
],
9494
)
9595
assert result.exit_code != 0
96-
assert "Missing option" in result.stdout
96+
assert "Missing option" in result.stderr
9797

9898

9999
def test_create_with_domain_and_command_creates_it(mock_website):
@@ -350,7 +350,7 @@ def test_reload_with_no_domain_barfs():
350350
],
351351
)
352352
assert result.exit_code != 0
353-
assert "Missing option" in result.stdout
353+
assert "Missing option" in result.stderr
354354

355355

356356
def test_reload_with_domain_reloads(mocker, mock_echo, mock_website):
@@ -379,7 +379,7 @@ def test_delete_with_no_domain_barfs():
379379
],
380380
)
381381
assert result.exit_code != 0
382-
assert "Missing option" in result.stdout
382+
assert "Missing option" in result.stderr
383383

384384

385385
def test_delete_with_domain_deletes_it(mocker, mock_echo, mock_website):

0 commit comments

Comments
 (0)