Пример #1
0
    def test_non_ascii_keyword_args_are_passed_without_corruption(self):
        def example_function(text):
            from sys import stdout
            stdout.buffer.write(text.encode("utf-8"))

        script = make_function_call_script(example_function, text="abc\u1234")
        self.assertEqual("abc\u1234", self.run_script(script).decode("utf-8"))
Пример #2
0
    def test_structured_arguments_are_passed_though_too(self):
        # Anything that can be JSON serialized can be passed.
        def example_function(arg):
            if arg == {"123": "foo", "bar": [4, 5, 6]}:
                print("Equal")
            else:
                print("Unequal, got %s" % repr(arg))

        script = make_function_call_script(example_function, {
            "123": "foo",
            "bar": [4, 5, 6]
        })
        self.assertEqual(b"Equal\n", self.run_script(script))
Пример #3
0
    def test_positional_and_keyword_args_get_passed_through(self):
        def example_function(a, b):
            print("a=%s, b=%d" % (a, b), end="")

        script = make_function_call_script(example_function, "foo", b=12345)
        self.assertEqual(b"a=foo, b=12345", self.run_script(script))
Пример #4
0
    def test_basic(self):
        def example_function():
            print("Hello, World!", end="")

        script = make_function_call_script(example_function)
        self.assertEqual(b"Hello, World!", self.run_script(script))