Skip to content

Commit 8293cce

Browse files
committed
Fix click library pytest issues
The update in click library by 8d49e146ab8c2312e7917bb7c3f8abf01b8b55bf produces two artifacts in our codebase which caused the CI tests to fail 1) Capitalization of `N` in `No such option` 2) Wrapping `help` so as to break line on terminal width This is solved by using an arbitrarily large `TERMINAL_WIDTH=1000` Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
1 parent bf767c2 commit 8293cce

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

tests/test_cli.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from deltacode import DeltaCode
4040
from deltacode import utils
4141

42+
TERMINAL_WIDTH = 1000
4243

4344
def load_csv(location):
4445
"""
@@ -82,7 +83,7 @@ def test_json_output_option_selected_all_selected(self):
8283
result_file = self.get_temp_file('json')
8384

8485
runner = CliRunner()
85-
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file, '-a'])
86+
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file, '-a'], terminal_width=TERMINAL_WIDTH)
8687

8788
assert result.exit_code == 0
8889

@@ -248,7 +249,7 @@ def test_json_output_option_selected_all_not_selected(self):
248249
result_file = self.get_temp_file('json')
249250

250251
runner = CliRunner()
251-
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file])
252+
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file], terminal_width=TERMINAL_WIDTH)
252253

253254
assert result.exit_code == 0
254255

@@ -350,7 +351,7 @@ def test_no_output_option_selected_all_selected(self):
350351
old_scan = self.get_test_loc('cli/scan_1_file_moved_old.json')
351352

352353
runner = CliRunner()
353-
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-a'])
354+
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-a'], terminal_width=TERMINAL_WIDTH)
354355

355356
assert result.exit_code == 0
356357

@@ -392,7 +393,7 @@ def test_no_output_option_selected_all_not_selected(self):
392393
old_scan = self.get_test_loc('cli/scan_1_file_moved_old.json')
393394

394395
runner = CliRunner()
395-
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan])
396+
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan], terminal_width=TERMINAL_WIDTH)
396397

397398
assert result.exit_code == 0
398399

@@ -434,7 +435,7 @@ def test_json_deltas_count_all_selected(self):
434435
result_file = self.get_temp_file('json')
435436

436437
runner = CliRunner()
437-
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file, '-a'])
438+
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file, '-a'], terminal_width=TERMINAL_WIDTH)
438439

439440
json_result = json.load(open(result_file))
440441

@@ -447,15 +448,15 @@ def test_json_deltas_count_all_not_selected(self):
447448
result_file = self.get_temp_file('json')
448449

449450
runner = CliRunner()
450-
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file])
451+
result = runner.invoke(cli.cli, ['-n', new_scan, '-o', old_scan, '-j', result_file], terminal_width=TERMINAL_WIDTH)
451452

452453
json_result = json.load(open(result_file))
453454

454455
assert json_result.get('deltas_count') == 4
455456

456457
def test_help(self):
457458
runner = CliRunner()
458-
result = runner.invoke(cli.cli, ['--help'])
459+
result = runner.invoke(cli.cli, ['--help'], terminal_width=TERMINAL_WIDTH)
459460

460461
assert 'Usage: cli [OPTIONS]' in result.output
461462
assert 'Identify the changes that need to be made' in result.output
@@ -465,19 +466,19 @@ def test_help(self):
465466

466467
def test_version(self):
467468
runner = CliRunner()
468-
result = runner.invoke(cli.cli, ['--version'])
469+
result = runner.invoke(cli.cli, ['--version'], terminal_width=TERMINAL_WIDTH)
469470

470471
assert 'DeltaCode version' in result.output
471472

472473
def test_empty(self):
473474
runner = CliRunner()
474-
result = runner.invoke(cli.cli, [])
475+
result = runner.invoke(cli.cli, [], terminal_width=TERMINAL_WIDTH)
475476

476477
assert 'Usage: cli [OPTIONS]' in result.output
477478
assert "Error: Missing option '-n' / '--new'." in result.output
478479

479480
def test_incorrect_flag(self):
480481
runner = CliRunner()
481-
result = runner.invoke(cli.cli, ['-xyz'])
482+
result = runner.invoke(cli.cli, ['-xyz'], terminal_width=TERMINAL_WIDTH)
482483

483-
assert 'Error: no such option: -x' in result.output
484+
assert 'Error: No such option: -x' in result.output

0 commit comments

Comments
 (0)