def test_log_result(self, log_mock, ll_mock, le_mock, stdout_mock): h = mock.Mock(spec=Harvester) h.as_json.return_value = mock.sentinel.json h.as_xml.return_value = mock.sentinel.xml h.to_terminal.side_effect = fake_to_terminal cli.log_result(h, json=True) h.as_json.assert_called_once_with() cli.log_result(h, json=True, xml=True) h.as_json.assert_called_twice_with() self.assertEqual(h.as_xml.call_count, 0) cli.log_result(h, xml=True) h.as_xml.assert_called_once_with() cli.log_result(h) h.to_terminal.assert_called_once_with() log_mock.assert_has_calls([ mock.call(mock.sentinel.json, noformat=True), mock.call(mock.sentinel.json, noformat=True), mock.call(mock.sentinel.xml, noformat=True), mock.call('a'), ]) le_mock.assert_called_once_with('mystr', indent=1) ll_mock.assert_has_calls([ mock.call(['b']), mock.call(('p1', 'p2'), indent=1), ])
def test_log_result(mocker, stdout_mock): le_mock = mocker.patch('radon.cli.log_error') ll_mock = mocker.patch('radon.cli.log_list') log_mock = mocker.patch('radon.cli.log') h = mocker.Mock(spec=Harvester) h.as_json.return_value = mocker.sentinel.json h.as_xml.return_value = mocker.sentinel.xml h.to_terminal.side_effect = fake_to_terminal cli.log_result(h, json=True) h.as_json.assert_called_once_with() h.as_json.reset_mock() cli.log_result(h, json=True, xml=True) h.as_json.assert_called_once_with() assert h.as_xml.call_count == 0 cli.log_result(h, xml=True) h.as_xml.assert_called_once_with() cli.log_result(h) h.to_terminal.assert_called_once_with() log_mock.assert_has_calls([ mocker.call(mocker.sentinel.json, noformat=True), mocker.call(mocker.sentinel.json, noformat=True), mocker.call(mocker.sentinel.xml, noformat=True), mocker.call('a'), ]) le_mock.assert_called_once_with('mystr', indent=1) ll_mock.assert_has_calls([ mocker.call(['b']), mocker.call(('p1', 'p2'), indent=1), ])
def analyze(paths): """ Analyze the files from the path specified """ config = Config( exclude=None, ignore=None, order=SCORE, no_assert=True, show_closures=False, min="A", max="F", show_complexity=True, total_average=True, average=True, ) h = CCHarvester(paths, config) log_result(h, stream=sys.stdout)