Ejemplo n.º 1
0
    def test_as_session_2(self):
        @cit.as_session('DEF')
        def func():
            print('ABC')

        with patch("sys.stdout", new=StringIO()) as fake_out:
            func()
            expect_word = "*\n| __DEF__________________________\nABC\n`\n"
            self.assertEqual(fake_out.getvalue(), expect_word)
Ejemplo n.º 2
0
    def test_as_session_3(self):
        @cit.as_session
        def underscore_orCamel():
            print('ABC')

        with patch("sys.stdout", new=StringIO()) as fake_out:
            underscore_orCamel()
            expect_word = "*\n| __UNDERSCORE OR CAMEL__________________________\nABC\n`\n"
            self.assertEqual(fake_out.getvalue(), expect_word)
Ejemplo n.º 3
0
 def test_pause(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("\n")):  # simulate press enter
         cit.pause()
         expect_word = "\nPress Enter to Continue..."
         self.assertEqual(fake_out.getvalue(), expect_word)
Ejemplo n.º 4
0
 def test_dim(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.dim("ABC")
         self.assertEqual(fake_out.getvalue(), "| ABC\n")
Ejemplo n.º 5
0
 def test_err(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.err("ABC")
         self.assertEqual(fake_out.getvalue(), "| (Error) ABC\n")
Ejemplo n.º 6
0
 def test_warn(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.warn("ABC")
         self.assertEqual(fake_out.getvalue(), "| (Warning) ABC\n")
Ejemplo n.º 7
0
 def test_info(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.info("ABC")
         self.assertEqual(fake_out.getvalue(), "| (Info) ABC\n")
Ejemplo n.º 8
0
 def test_title(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.title("ABC")
         self.assertEqual(fake_out.getvalue(), '| __ABC__________________________\n')
Ejemplo n.º 9
0
 def test_get_choices_exitable(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("0\n")):
         self.assertEqual(cit.get_choices(["ABC", "DEF"], exitable=True), [])
         expect_word = "0) ** EXIT **"
         self.assertTrue(expect_word in fake_out.getvalue())
Ejemplo n.º 10
0
 def test_br(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.br(2)
         self.assertEqual(fake_out.getvalue(), '\n\n')
Ejemplo n.º 11
0
 def test_end(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.end()
         self.assertEqual(fake_out.getvalue(), '`\n')
Ejemplo n.º 12
0
 def test_get_choices_allable_unselect(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("a\na\n0\n")):  # allable on, unselect all.
         self.assertEqual(cit.get_choices(["ABC", "DEF"], allable=True, exitable=True), [])
         expect_word = "[+] ABC"
         self.assertTrue(expect_word in fake_out.getvalue())
Ejemplo n.º 13
0
 def test_get_choices_allable_esc(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("all\n0\n")):  # allable off
         self.assertEqual(cit.get_choices(["a", "DEF"], allable=True, exitable=True), ["a", "DEF"])
         expect_word = "all) ** ALL **"
         self.assertTrue(expect_word in fake_out.getvalue())
Ejemplo n.º 14
0
 def test_get_choices_allable_off(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("a\n0\n")):  # allable off
         self.assertEqual(cit.get_choices(["ABC", "DEF"], exitable=True), [])
         expect_word = "Please enter a valid choice."
         self.assertTrue(expect_word in fake_out.getvalue())
Ejemplo n.º 15
0
 def test_get_input(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("ABC\n")):
         userinput = cit.get_input()
         self.assertEqual(fake_out.getvalue(), "> ")
         self.assertEqual(userinput, "ABC")
Ejemplo n.º 16
0
 def test_echo_pre(self):
     with patch("sys.stdout", new=StringIO()) as fake_out:
         cit.echo("ABC", pre="prefix")
         self.assertEqual(fake_out.getvalue(), "| (Prefix) ABC\n")
Ejemplo n.º 17
0
 def test_get_choice_index(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("1\n")):
         self.assertEqual(cit.get_choice(["ABC", "DEF"]), "ABC")
         expect_word = "|  1) ABC\n|  2) DEF\n> "
         self.assertEqual(fake_out.getvalue(), expect_word)
Ejemplo n.º 18
0
 def test_get_choices_done_esc(self):
     with patch("sys.stdout", new=StringIO()) as fake_out, patch("sys.stdin", new=StringIO("1\ndone\n")):
         self.assertEqual(cit.get_choices(["ABC", "0"]), ["ABC", ])
         expect_word = "done) ** DONE **"
         self.assertTrue(expect_word in fake_out.getvalue())