Esempio n. 1
0
    def test_show_bears(self):
        with retrieve_stdout() as stdout:
            bears = {SomelocalBear: ['default', 'test'],
                     SomeglobalBear: ['default', 'test']}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = stdout.getvalue()
        self.maxDiff = None
        with retrieve_stdout() as stdout:
            show_bears(self.local_bears,
                       self.global_bears,
                       False,
                       self.log_printer.printer)
            self.assertEqual(expected_string, stdout.getvalue())

        with retrieve_stdout() as stdout:
            show_bears(self.local_bears,
                       self.global_bears,
                       True,
                       self.log_printer.printer)
            self.assertEqual("SomeglobalBear\n"
                             "==============\n"
                             "Some global-bear Description.\n"
                             "\n"
                             "SomelocalBear\n"
                             "=============\n"
                             "Some local-bear Description.\n\n",
                             stdout.getvalue())
Esempio n. 2
0
 def test_print_bears_empty(self):
     with retrieve_stdout() as stdout:
         bears = {}
         print_bears(self.log_printer.printer, bears, True)
         self.assertEqual("No bears to show.\n", stdout.getvalue())
     with retrieve_stdout() as stdout:
         bears = {}
         print_bears(self.log_printer.printer, bears, False)
         self.assertEqual("No bears to show.\n", stdout.getvalue())
Esempio n. 3
0
 def test_print_bears_empty(self):
     with retrieve_stdout() as stdout:
         bears = {}
         print_bears(self.log_printer.printer, bears, True)
         self.assertEqual("No bears to show.\n", stdout.getvalue())
     with retrieve_stdout() as stdout:
         bears = {}
         print_bears(self.log_printer.printer, bears, False)
         self.assertEqual("No bears to show.\n", stdout.getvalue())
Esempio n. 4
0
    def test_print_bears_no_sections(self):
        with retrieve_stdout() as stdout:
            bears = {SomeBear: []}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "SomeBear:\n"
            expected_string += "  Some Description.\n\n"
            expected_string += "  No sections.\n\n"
            expected_string += "  No needed settings.\n\n"
            expected_string += "  No optional settings.\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 5
0
    def test_print_bears_no_sections(self):
        with retrieve_stdout() as stdout:
            bears = {SomeBear: []}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "SomeBear:\n"
            expected_string += "  Some Description.\n\n"
            expected_string += "  No sections.\n\n"
            expected_string += "  No needed settings.\n\n"
            expected_string += "  No optional settings.\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
    def test_print_bears_no_settings(self):
        with retrieve_stdout() as stdout:
            bears = {SomeBear: ["default"]}
            print_bears(self.log_printer.printer, bears)
            expected_string = "SomeBear:\n"
            expected_string += "  " + "Some Description." + "\n\n"
            expected_string += "  " + _("Used in:") + "\n"
            expected_string += "   * default\n\n"
            expected_string += "  " + _("No needed settings.") + "\n\n"
            expected_string += "  " + _("No optional settings.") + "\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 7
0
    def test_print_bears_no_optional_settings(self):
        with retrieve_stdout() as stdout:
            bears = {TestBear2: ["test"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "TestBear2:\n"
            expected_string += "  Test bear 2 description.\n\n"
            expected_string += "  Used in:\n"
            expected_string += "   * test\n\n"
            expected_string += "  Needed Settings:\n"
            expected_string += "   * setting1: Required Setting.\n\n"
            expected_string += "  No optional settings.\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 8
0
    def test_print_bears_no_optional_settings(self):
        with retrieve_stdout() as stdout:
            bears = {TestBear2: ["test"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "TestBear2:\n"
            expected_string += "  Test bear 2 description.\n\n"
            expected_string += "  Used in:\n"
            expected_string += "   * test\n\n"
            expected_string += "  Needed Settings:\n"
            expected_string += "   * setting1: Required Setting.\n\n"
            expected_string += "  No optional settings.\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 9
0
    def test_show_bears(self):
        with retrieve_stdout() as stdout:
            bears = {KeywordBear: ["default", "test"], LineLengthBear: ["test"], SomeglobalBear: ["default", "test"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = stdout.getvalue()
        self.maxDiff = None
        with retrieve_stdout() as stdout:
            show_bears(self.local_bears, self.global_bears, False, self.log_printer.printer)
            self.assertEqual(expected_string, stdout.getvalue())

        with retrieve_stdout() as stdout:
            show_bears(self.local_bears, self.global_bears, True, self.log_printer.printer)
            self.assertEqual(" * KeywordBear\n" " * LineLengthBear\n" " * SomeglobalBear\n", stdout.getvalue())
 def test_show_bears(self):
     with retrieve_stdout() as stdout:
         bears = {KeywordBear: ['default', 'test'],
                  LineLengthBear: ['test'],
                  SomeglobalBear: ['default', 'test']}
         print_bears(self.log_printer.printer, bears)
         expected_string = stdout.getvalue()
     self.maxDiff = None
     with retrieve_stdout() as stdout:
         show_bears(self.local_bears,
                    self.global_bears,
                    self.log_printer.printer)
         self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 11
0
    def test_print_bears_no_sections(self):
        with retrieve_stdout() as stdout:
            bears = {SomeBear: []}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "SomeBear:\n"
            expected_string += "  Some Description.\n\n"
            expected_string += ("  The bear does not provide information "
                                "about which languages it can analyze.\n\n")
            expected_string += "  No sections.\n\n"
            expected_string += "  No needed settings.\n\n"
            expected_string += "  No optional settings.\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
    def test_print_bears_no_optional_settings(self):
        with retrieve_stdout() as stdout:
            bears = {TestBear2: ["test"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "TestBear2:\n"
            expected_string += "  Test bear 2 description.\n\n"
            expected_string += ("  The bear does not provide information "
                                "about which languages it can analyze.\n\n")
            expected_string += "  Used in:\n"
            expected_string += "   * test\n\n"
            expected_string += "  Needed Settings:\n"
            expected_string += "   * setting1: Required Setting.\n\n"
            expected_string += "  No optional settings.\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 13
0
    def test_print_bears_no_needed_settings(self):
        with retrieve_stdout() as stdout:
            bears = {SomeOtherBear: ["test"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "SomeOtherBear:\n"
            expected_string += "  This is a Bear.\n\n"
            expected_string += "  Used in:\n"
            expected_string += "   * test\n\n"
            expected_string += "  No needed settings.\n\n"
            expected_string += "  Optional Settings:\n"
            expected_string += "   * setting: This is an optional setting. ("
            expected_string += "Optional, defaults to 'None'."
            expected_string += ")\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 14
0
    def test_print_bears_no_needed_settings(self):
        with retrieve_stdout() as stdout:
            bears = {SomeOtherBear: ["test"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "SomeOtherBear:\n"
            expected_string += "  This is a Bear.\n\n"
            expected_string += "  Used in:\n"
            expected_string += "   * test\n\n"
            expected_string += "  No needed settings.\n\n"
            expected_string += "  Optional Settings:\n"
            expected_string += "   * setting: This is an optional setting. ("
            expected_string += "Optional, defaults to 'None'."
            expected_string += ")\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
    def test_print_bears_no_needed_settings(self):
        with retrieve_stdout() as stdout:
            bears = {SomeOtherBear: ["test"]}
            print_bears(self.log_printer.printer, bears)
            expected_string = "SomeOtherBear:\n"
            expected_string += "  " + "This is a Bear." + "\n\n"
            expected_string += "  " + _("Used in:") + "\n"
            expected_string += "   * test\n\n"
            expected_string += "  " + _("No needed settings.") + "\n\n"
            expected_string += "  " + _("Optional Settings:") + "\n"
            expected_string += "   * setting: This is an optional setting. ("
            expected_string += _("Optional, defaults to '{}'.").format("None")
            expected_string += ")\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 16
0
    def test_print_bears(self):
        with retrieve_stdout() as stdout:
            bears = {TestBear: ["default", "docs"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "TestBear:\n"
            expected_string += "  Test bear Description.\n\n"
            expected_string += "  Used in:\n"
            expected_string += "   * default\n"
            expected_string += "   * docs\n\n"
            expected_string += "  Needed Settings:\n"
            expected_string += "   * setting1: Required Setting.\n\n"
            expected_string += "  Optional Settings:\n"
            expected_string += "   * setting2: Optional Setting. ("
            expected_string += "Optional, defaults to 'None'."
            expected_string += ")\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 17
0
    def test_print_bears(self):
        with retrieve_stdout() as stdout:
            bears = {TestBear: ["default", "docs"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "TestBear:\n"
            expected_string += "  Test bear Description.\n\n"
            expected_string += "  Used in:\n"
            expected_string += "   * default\n"
            expected_string += "   * docs\n\n"
            expected_string += "  Needed Settings:\n"
            expected_string += "   * setting1: Required Setting.\n\n"
            expected_string += "  Optional Settings:\n"
            expected_string += "   * setting2: Optional Setting. ("
            expected_string += "Optional, defaults to 'None'."
            expected_string += ")\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
Esempio n. 18
0
    def test_print_bears_no_needed_settings(self):
        with retrieve_stdout() as stdout:
            bears = {SomeOtherBear: ["test"]}
            print_bears(self.log_printer.printer, bears, False)
            expected_string = "SomeOtherBear:\n"
            expected_string += "  This is a Bear.\n\n"
            expected_string += ("  The bear does not provide information "
                                "about which languages it can analyze.\n\n")
            expected_string += "  Used in:\n"
            expected_string += "   * test\n\n"
            expected_string += "  No needed settings.\n\n"
            expected_string += "  Optional Settings:\n"
            expected_string += "   * setting: This is an optional setting. ("
            expected_string += "Optional, defaults to 'None'."
            expected_string += ")\n\n"

            self.assertEqual(expected_string, stdout.getvalue())
    def test_show_bears(self):
        with retrieve_stdout() as stdout:
            bears = {
                KeywordBear: ['default', 'test'],
                LineLengthBear: ['test'],
                SomeglobalBear: ['default', 'test']
            }
            print_bears(self.log_printer.printer, bears, False)
            expected_string = stdout.getvalue()
        self.maxDiff = None
        with retrieve_stdout() as stdout:
            show_bears(self.local_bears, self.global_bears, False,
                       self.log_printer.printer)
            self.assertEqual(expected_string, stdout.getvalue())

        with retrieve_stdout() as stdout:
            show_bears(self.local_bears, self.global_bears, True,
                       self.log_printer.printer)
            self.assertEqual(
                " * KeywordBear\n"
                " * LineLengthBear\n"
                " * SomeglobalBear\n", stdout.getvalue())