Example #1
0
    def test_builtin_python_function_with_no_stream(self):
        """Test procedure that needs a stream, but is passed None."""

        p = BuiltinProcedure(lambda x, y: y.write('42'), True, None)
        result = p.apply(None, None)
        # Just make sure it runs
        self.assertTrue(True)
Example #2
0
    def test_builtin_python_function_with_stream(self):
        """Test procedure that needs a stream."""

        stream = StringIO.StringIO()
        p = BuiltinProcedure(lambda x, y: y.write('42'), True, stream)
        result = p.apply(None, None)
        stream.seek(0)
        self.assertEqual(stream.read(), '42')
Example #3
0
    def test_builtin_python_function(self):
        """Test normal builtin procedure."""

        p = BuiltinProcedure(lambda x: x[0] + x[1])
        result = p.apply(None, [1, 2])
        self.assertEqual(result, 3)