コード例 #1
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))
コード例 #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_non_ascii_keyword_args_are_passed_without_corruption(self):
     def example_function(text):
         print(repr(text), end="")
     script = make_function_call_script(example_function, text="abc\u1234")
     self.assertEqual(b"u'abc\\u1234'", self.run_script(script))
コード例 #4
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))
コード例 #5
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))
コード例 #6
0
    def test_non_ascii_keyword_args_are_passed_without_corruption(self):
        def example_function(text):
            print(repr(text), end="")

        script = make_function_call_script(example_function, text="abc\u1234")
        self.assertEqual(b"u'abc\\u1234'", self.run_script(script))
コード例 #7
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))
コード例 #8
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))