Пример #1
0
    def _get_report(self):
        out = []
        report_header = '\nImport Report'
        out.append(report_header)
        for module_name in sorted(self._import_data.keys()):
            out += self._get_module_report(module_name, has_header=True)

        if not self._required_packages:
            return formatter.format_output(out, width=self._width)

        required_extras = sorted(
            set(self._required_packages).difference(self._import_data.keys()))
        if required_extras:
            msg = 'Following packages are required but never imported:'
            out.append(formatter.format_header(msg=msg, width=self._width))
            out.append(formatter.format_iterable(required_extras))
        return formatter.format_output(out, width=self._width)
Пример #2
0
    def test_module_report(self):
        for module in self.import_reporter.modules:
            test_module_report = formatter.format_output(
                self._get_module_report(module),
                width=self.width,
            )

            reporter_module_report = self.import_reporter.module_report(module)
            self.assertEqual(reporter_module_report, test_module_report)
Пример #3
0
 def module_report(self, module_name):
     return formatter.format_output(self._get_module_report(module_name),
                                    width=self._width)
Пример #4
0
 def test_format_output(self):
     self.assertEquals(
         formatter.format_output(self.iterable, width=3),
         self.expected_string_05,
     )