Method: pylint.lint.pylinter.PyLinter._load_reporters
Calls: 32, Exceptions: 3, Paths: 4Back
Path 1: 26 calls (0.81)
'text' (20) 'parseable' (2) 'msvs' (1) 'colorized' (1) 'json' (1) 'no-header' (1)
1def _load_reporters(self, reporter_names: str) -> None:
2 """Load the reporters if they are available on _reporters."""
3 if not self._reporters:
4 return
5 sub_reporters = []
6 output_files = []
7 with contextlib.ExitStack() as stack:
8 for reporter_name in reporter_names.split(","):
9 reporter_name, *reporter_output = reporter_name.split(":", 1)
10
11 reporter = self._load_reporter_by_name(reporter_name)
12 sub_reporters.append(reporter)
13 if reporter_output:
14 output_file = stack.enter_context(
15 open(reporter_output[0], "w", encoding="utf-8")
16 )
17 reporter.out = output_file
18 output_files.append(output_file)
19
20 # Extend the lifetime of all opened output files
21 close_output_files = stack.pop_all().close
22
23 if len(sub_reporters) > 1 or output_files:
24 self.set_reporter(
25 reporters.MultiReporter(
26 sub_reporters,
27 close_output_files,
28 )
29 )
30 else:
31 self.set_reporter(sub_reporters[0])
Path 2: 3 calls (0.09)
'missing.module.Class' (1) 'lint.unittest_lint._CustomPyLinter' (1) 'lint.unittest_lint.MyReporter' (1)
InvalidReporterError (3)
1def _load_reporters(self, reporter_names: str) -> None:
2 """Load the reporters if they are available on _reporters."""
3 if not self._reporters:
4 return
5 sub_reporters = []
6 output_files = []
7 with contextlib.ExitStack() as stack:
8 for reporter_name in reporter_names.split(","):
9 reporter_name, *reporter_output = reporter_name.split(":", 1)
10
11 reporter = self._load_reporter_by_name(reporter_name)
12 sub_reporters.append(reporter)
13 if reporter_output:
14 output_file = stack.enter_context(
15 open(reporter_output[0], "w", encoding="utf-8")
16 )
17 reporter.out = output_file
18 output_files.append(output_file)
19
20 # Extend the lifetime of all opened output files
21 close_output_files = stack.pop_all().close
22
23 if len(sub_reporters) > 1 or output_files:
24 self.set_reporter(
25 reporters.MultiReporter(
26 sub_reporters,
27 close_output_files,
28 )
29 )
30 else:
31 self.set_reporter(sub_reporters[0])
Path 3: 2 calls (0.06)
'text' (1) 'parseable' (1)
None (2)
1def _load_reporters(self, reporter_names: str) -> None:
2 """Load the reporters if they are available on _reporters."""
3 if not self._reporters:
4 return
5 sub_reporters = []
6 output_files = []
7 with contextlib.ExitStack() as stack:
8 for reporter_name in reporter_names.split(","):
9 reporter_name, *reporter_output = reporter_name.split(":", 1)
10
11 reporter = self._load_reporter_by_name(reporter_name)
12 sub_reporters.append(reporter)
13 if reporter_output:
14 output_file = stack.enter_context(
15 open(reporter_output[0], "w", encoding="utf-8")
16 )
17 reporter.out = output_file
18 output_files.append(output_file)
19
20 # Extend the lifetime of all opened output files
21 close_output_files = stack.pop_all().close
22
23 if len(sub_reporters) > 1 or output_files:
24 self.set_reporter(
25 reporters.MultiReporter(
26 sub_reporters,
27 close_output_files,
28 )
29 )
30 else:
31 self.set_reporter(sub_reporters[0])
Path 4: 1 calls (0.03)
'json:/private/var/folders/yp/qx0crmvd4sbck7chb52sws500000gn/T/pytest-of-andrehora/pytest-178/test_multi_format_output0/somefile.json,text,unittest_re...
1def _load_reporters(self, reporter_names: str) -> None:
2 """Load the reporters if they are available on _reporters."""
3 if not self._reporters:
4 return
5 sub_reporters = []
6 output_files = []
7 with contextlib.ExitStack() as stack:
8 for reporter_name in reporter_names.split(","):
9 reporter_name, *reporter_output = reporter_name.split(":", 1)
10
11 reporter = self._load_reporter_by_name(reporter_name)
12 sub_reporters.append(reporter)
13 if reporter_output:
14 output_file = stack.enter_context(
15 open(reporter_output[0], "w", encoding="utf-8")
16 )
17 reporter.out = output_file
18 output_files.append(output_file)
19
20 # Extend the lifetime of all opened output files
21 close_output_files = stack.pop_all().close
22
23 if len(sub_reporters) > 1 or output_files:
24 self.set_reporter(
25 reporters.MultiReporter(
26 sub_reporters,
27 close_output_files,
28 )
29 )
30 else:
31 self.set_reporter(sub_reporters[0])