@@ -85,6 +85,34 @@ def _load_json_result(result_file):
8585 return scan_result
8686
8787
88+ def test_json_pretty_print_option (monkeypatch ):
89+ monkeypatch .setattr (click ._termui_impl , 'isatty' , lambda _ : True )
90+ test_dir = test_env .get_test_loc ('json-option' , copy = True )
91+ runner = CliRunner ()
92+ result_file = test_env .get_temp_file ('json' )
93+ result = runner .invoke (cli .scancode , ['--copyright' , '--format' , 'json-pp' , test_dir , result_file ], catch_exceptions = True )
94+ assert result .exit_code == 0
95+ assert 'Scanning done' in result .output
96+ assert 'copyright_acme_c-c.c' in result .output
97+ assert os .path .exists (result_file )
98+ assert len (open (result_file ).read ()) > 10
99+ assert len (open (result_file ).readlines ()) > 1
100+
101+
102+ def test_json_output_option_is_minified (monkeypatch ):
103+ monkeypatch .setattr (click ._termui_impl , 'isatty' , lambda _ : True )
104+ test_dir = test_env .get_test_loc ('json-option' , copy = True )
105+ runner = CliRunner ()
106+ result_file = test_env .get_temp_file ('json' )
107+ result = runner .invoke (cli .scancode , ['--copyright' , '--format' , 'json' , test_dir , result_file ], catch_exceptions = True )
108+ assert result .exit_code == 0
109+ assert 'Scanning done' in result .output
110+ assert 'copyright_acme_c-c.c' in result .output
111+ assert os .path .exists (result_file )
112+ assert len (open (result_file ).read ()) > 10
113+ assert len (open (result_file ).readlines ()) == 1
114+
115+
88116def test_package_option_detects_packages (monkeypatch ):
89117 monkeypatch .setattr (click ._termui_impl , 'isatty' , lambda _ : True )
90118 test_dir = test_env .get_test_loc ('package' , copy = True )
0 commit comments