Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_formatter_types(self):
summary = {'started': datetime.datetime(2014, 1, 1),
'completed': datetime.datetime(2014, 1, 1),
'message_count': 0,
'time_taken': '0',
'libraries': [],
'strictness': 'veryhigh',
'profiles': '',
'tools': []}
profile = ProspectorProfile(name='horse',
profile_dict={},
inherit_order=['horse'])
for formatter_name, formatter in FORMATTERS.items():
formatter_instance = formatter(summary, [], profile)
self.assertIsInstance(formatter_instance.render(True, True, False),
six.string_types)
manager.add(soc.ListSetting('uses', soc.String, default=[]))
manager.add(soc.BooleanSetting('blending', default=True))
manager.add(soc.BooleanSetting('doc_warnings', default=None))
manager.add(soc.BooleanSetting('test_warnings', default=None))
manager.add(soc.BooleanSetting('no_style_warnings', default=None))
manager.add(soc.BooleanSetting('member_warnings', default=None))
manager.add(soc.BooleanSetting('full_pep8', default=None))
manager.add(soc.IntegerSetting('max_line_length', default=None))
manager.add(soc.BooleanSetting('messages_only', default=False))
manager.add(soc.BooleanSetting('summary_only', default=False))
manager.add(soc.ListSetting(
'output_format',
OutputChoice(sorted(FORMATTERS.keys())),
default=None,
))
manager.add(soc.BooleanSetting('absolute_paths', default=False))
manager.add(soc.ListSetting(
'tools',
soc.Choice(sorted(TOOLS.keys())),
default=None,
))
manager.add(soc.ListSetting('with_tools', soc.String, default=[]))
manager.add(soc.ListSetting('without_tools', soc.String, default=[]))
manager.add(soc.ListSetting('profiles', soc.String, default=[]))
manager.add(soc.ListSetting('profile_path', soc.String, default=[]))
manager.add(soc.ChoiceSetting(
'strictness',
['veryhigh', 'high', 'medium', 'low', 'verylow'],
},
'messages_only': {
'flags': ['-M', '--messages-only'],
'help': 'Only output message information (don\'t output summary'
' information about the checks)',
},
'summary_only': {
'flags': ['-S', '--summary-only'],
'help': 'Only output summary information about the checks (don\'t'
'output message information)',
},
'output_format': {
'flags': ['-o', '--output-format'],
'help': 'The output format. Valid values are: %s. This will output to stdout by default, however a target file can be used instead by adding :path-to-output-file, eg, -o json:output.json' % (
', '.join(sorted(FORMATTERS.keys())),
),
},
'absolute_paths': {
'help': 'Whether to output absolute paths when referencing files '
'in messages. By default, paths will be relative to the '
'project path',
},
'tools': {
'flags': ['-t', '--tool'],
'help': 'A list of tools to run. This lets you set exactly which '
'tools to run. To add extra tools to the defaults, see '
'--with-tool. Possible values are: %s. By '
'default, the following tools will be run: %s' % (
', '.join(sorted(TOOLS.keys())),
', '.join(sorted(DEFAULT_TOOLS)),
),
parser.add_argument(
'-i', '--ignore-paths', nargs='+',
help='A list of file or directory names to ignore. If the complete'
' name matches any of the items in this list, the file or '
' directory (and all subdirectories) will be ignored.'
)
parser.add_argument(
'-M', '--messages-only', default=False, action='store_true',
help="Only output message information (don't output summary"
" information about the checks)",
)
parser.add_argument(
'-o', '--output-format', default='text', help="The output format.",
choices=sorted(FORMATTERS.keys())
)
parser.add_argument(
'-p', '--path',
help="The path to the python project to inspect (defaults to PWD)",
)
parser.add_argument(
'checkpath', nargs='?', default=None,
help="The path to the python project to inspect (defaults to PWD)",
)
profiles_help = "The list of profiles to load. A profile is a certain" \
" 'type' of behaviour for prospector, and is represented by a YAML" \
" configuration file. A full path to the YAML file describing the" \
" profile must be provided. (see --strictness)"
def print_messages(self):
output_reports = self.config.get_output_report()
for report in output_reports:
output_format, output_files = report
self.summary['formatter'] = output_format
formatter = FORMATTERS[output_format](self.summary, self.messages, self.config.profile)
if not output_files:
self.write_to(formatter, sys.stdout)
for output_file in output_files:
with open(output_file, 'w+') as target:
self.write_to(formatter, target)