Example #1
0
 def test_log_progress_reports_FAILED(self):
     with utils.capture() as out:
         with self.assertRaises(KeyError):
             with utils.log_progress("Testing log message"):
                 raise KeyError
     self.assertTrue('Testing log message' in out[0])
     self.assertTrue('FAILED' in out[0])
Example #2
0
 def test_log_progress_reports_FAILED(self):
     with utils.capture() as out:
         with self.assertRaises(KeyError):
             with utils.log_progress("Testing log message"):
                 raise KeyError
     self.assertTrue('Testing log message' in out[0])
     self.assertTrue('FAILED' in out[0])
Example #3
0
    def test_create_initial_env(self):
        with utils.capture() as out:
            env = glob.create_initial_env()

        self.assertEqual(env.local_stack, [])
        self.assertTrue(len(env.global_frame) > 0)
        self.assertTrue('Creating initial environment' in out[0])
Example #4
0
    def test_docstring(self):
        prim = TestPrimitive()
        prim.__docstring__ = "Some documentation"
        with utils.capture() as out:
            glob.doc(prim)

        self.assertEqual('-----------------\nSome documentation\n', out[0])
Example #5
0
    def test_create_initial_env(self):
        with utils.capture() as out:
            env = glob.create_initial_env()

        self.assertEqual(env.local_stack, [])
        self.assertTrue(len(env.global_frame) > 0)
        self.assertTrue('Creating initial environment' in out[0])
Example #6
0
    def test_docstring(self):
        prim = TestPrimitive()
        prim.__docstring__ = "Some documentation"
        with utils.capture() as out:
            glob.doc(prim)

        self.assertEqual('-----------------\nSome documentation\n', out[0])
Example #7
0
    def test_print(self):
        testcases = [(None, ''), ([1], '1'), (['a'], 'a'),
                     (['a', 'b', 1, None, 2, 3], 'ab123')]

        for test_value, expected in testcases:
            with utils.capture() as out:
                glob.print_(test_value)
            self.assertEqual(expected + '\n', out[0])
Example #8
0
    def test_repl_starts_OK(self):
        commands = send_inputs("(+ 1 2 3 4)", "(iterate inc 0)", KeyboardInterrupt())
        results = {}
        collector = capture_outputs(results)

        with utils.capture() as out:
            repl.repl(inprompt=commands, outprompt=collector)

        self.assertEqual("10", results[1])
        self.assertEqual("(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...)", results[2])
        self.assertTrue("KeyboardInterrupt" in out[0])
        self.assertTrue("Bye!" in out[0])
Example #9
0
    def test_print(self):
        testcases = [
            (None, ''),
            ([1], '1'),
            (['a'], 'a'),
            (['a', 'b', 1, None, 2, 3], 'ab123')
        ]

        for test_value, expected in testcases:
            with utils.capture() as out:
                glob.print_(test_value)
            self.assertEqual(expected + '\n', out[0])
Example #10
0
    def test_repl_starts_OK(self):
        commands = send_inputs("(+ 1 2 3 4)", "(iterate inc 0)",
                               KeyboardInterrupt())
        results = {}
        collector = capture_outputs(results)

        with utils.capture() as out:
            repl.repl(inprompt=commands, outprompt=collector)

        self.assertEqual('10', results[1])
        self.assertEqual('(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...)', results[2])
        self.assertTrue('KeyboardInterrupt' in out[0])
        self.assertTrue('Bye!' in out[0])
Example #11
0
 def test_log_progress_reports_DONE(self):
     with utils.capture() as out:
         with utils.log_progress("Testing log message"):
             pass
     self.assertTrue('Testing log message' in out[0])
     self.assertTrue('DONE' in out[0])
Example #12
0
    def test_init_readline(self):
        with utils.capture() as out:
            repl.init_readline({})

        self.assertTrue('Reading history' in out[0])
        self.assertTrue('DONE' in out[0] or 'FAILED' in out[0])
Example #13
0
 def test_log_progress_reports_DONE(self):
     with utils.capture() as out:
         with utils.log_progress("Testing log message"):
             pass
     self.assertTrue('Testing log message' in out[0])
     self.assertTrue('DONE' in out[0])
Example #14
0
    def test_init_readline(self):
        with utils.capture() as out:
            repl.init_readline({})

        self.assertTrue("Reading history" in out[0])
        self.assertTrue("DONE" in out[0] or "FAILED" in out[0])
Example #15
0
    def test_docstring_None(self):
        with utils.capture() as out:
            glob.doc(TestPrimitive())

        self.assertEqual('', out[0])
Example #16
0
    def test_docstring_None(self):
        with utils.capture() as out:
            glob.doc(TestPrimitive())

        self.assertEqual('', out[0])