当前位置: 首页>>代码示例>>Python>>正文


Python builtins.create_builtins_module函数代码示例

本文整理汇总了Python中modules.builtins.create_builtins_module函数的典型用法代码示例。如果您正苦于以下问题:Python create_builtins_module函数的具体用法?Python create_builtins_module怎么用?Python create_builtins_module使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_builtins_module函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_w_when_no_exception_in_code_then_handler_not_triggered

    def test_w_when_no_exception_in_code_then_handler_not_triggered(self):
        # when
        result = eval_str('''(try
                                "code"
                             (except
                                "exc")
                             (finally
                                "fin"))''',
                          create_builtins_module())
        # then
        self.assertIsInstance(result, WString)
        self.assertEqual("code", result)
        # when
        result = eval_str('''(try
                                "code"
                             (except
                                "exc"))''',
                          create_builtins_module())
        # then
        self.assertIsInstance(result, WString)
        self.assertEqual("code", result)

        # when
        result = eval_str('''(try
                                "code"
                             (except
                                (raise "exc")))''',
                          create_builtins_module())
        # then
        self.assertIsInstance(result, WString)
        self.assertEqual("code", result)
开发者ID:izrik,项目名称:wodehouse,代码行数:31,代码来源:try_tests.py

示例2: test_mult_mults_numbers

 def test_mult_mults_numbers(self):
     # when
     result = mult(WNumber(1), WNumber(2), WNumber(3), WNumber(4))
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(24, result)
     # when
     result = eval_str("(* 1 2 3 4)", create_builtins_module())
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(24, result)
     # when
     result = mult(WNumber(3), WNumber(2))
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(6, result)
     # when
     result = eval_str("(* 3 2)", create_builtins_module())
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(6, result)
     # when
     result = mult(WNumber(5), WNumber(2))
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(10, result)
     # when
     result = eval_str("(* 5 2)", create_builtins_module())
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(10, result)
开发者ID:izrik,项目名称:wodehouse,代码行数:31,代码来源:mult_tests.py

示例3: test_w_exception_in_finally_overrides_retval_in_code

 def test_w_exception_in_finally_overrides_retval_in_code(self):
     # when
     result = eval_str('''(try
                             "code"
                          (except
                             "exc")
                          (finally
                             (raise "fin")))''',
                       create_builtins_module())
     # then
     self.assertIsInstance(result, WRaisedException)
     self.assertIsInstance(result.exception, WException)
     self.assertEqual("fin", result.exception.message)
     # when
     result = eval_str('''(try
                             "code"
                          (except
                             (raise "exc"))
                          (finally
                             (raise "fin")))''',
                       create_builtins_module())
     # then
     self.assertIsInstance(result, WRaisedException)
     self.assertIsInstance(result.exception, WException)
     self.assertEqual("fin", result.exception.message)
     # when
     result = eval_str('''(try
                             "code"
                          (finally
                             (raise "fin")))''',
                       create_builtins_module())
     # then
     self.assertIsInstance(result, WRaisedException)
     self.assertIsInstance(result.exception, WException)
     self.assertEqual("fin", result.exception.message)
开发者ID:izrik,项目名称:wodehouse,代码行数:35,代码来源:try_tests.py

示例4: test_sub_subs_numbers

 def test_sub_subs_numbers(self):
     # when
     result = sub(WNumber(1), WNumber(2), WNumber(3), WNumber(4))
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(-8, result)
     # when
     result = eval_str("(- 1 2 3 4)", create_builtins_module())
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(-8, result)
     # when
     result = sub(WNumber(3), WNumber(2))
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(1, result)
     # when
     result = eval_str("(- 3 2)", create_builtins_module())
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(1, result)
     # when
     result = sub(WNumber(5), WNumber(1), WNumber(1))
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(3, result)
     # when
     result = eval_str("(- 5 1 1)", create_builtins_module())
     # then
     self.assertIsInstance(result, WNumber)
     self.assertEqual(3, result)
开发者ID:izrik,项目名称:wodehouse,代码行数:31,代码来源:sub_tests.py

示例5: test_get_gets_value_by_key

 def test_get_gets_value_by_key(self):
     # when
     result = eval_str("(get (new_scope '((a 1) (b 2))) 'a)",
                       create_builtins_module())
     # then
     self.assertEqual(1, result)
     # when
     result = eval_str("(get (new_scope '((a 1) (b 2))) 'b)",
                       create_builtins_module())
     # then
     self.assertEqual(2, result)
开发者ID:izrik,项目名称:wodehouse,代码行数:11,代码来源:get_scope_value_tests.py

示例6: test_or_returns_true_if_any_true

 def test_or_returns_true_if_any_true(self):
     # when
     result = eval_str("(or false true)", create_builtins_module())
     # then
     self.assertIs(WBoolean.true, result)
     # when
     result = eval_str("(or true false)", create_builtins_module())
     # then
     self.assertIs(WBoolean.true, result)
     # when
     result = eval_str("(or true true)", create_builtins_module())
     # then
     self.assertIs(WBoolean.true, result)
开发者ID:izrik,项目名称:wodehouse,代码行数:13,代码来源:w_or_tests.py

示例7: test_and_returns_false_if_any_false

 def test_and_returns_false_if_any_false(self):
     # when
     result = eval_str("(and false true)", create_builtins_module())
     # then
     self.assertIs(WBoolean.false, result)
     # when
     result = eval_str("(and true false)", create_builtins_module())
     # then
     self.assertIs(WBoolean.false, result)
     # when
     result = eval_str("(and false false)", create_builtins_module())
     # then
     self.assertIs(WBoolean.false, result)
开发者ID:izrik,项目名称:wodehouse,代码行数:13,代码来源:w_and_tests.py

示例8: test_maps_with_named_function

 def test_maps_with_named_function(self):
     # when
     result = eval_str(
         "(map car '((1 2 3) (a b c) (\"a\" \"b\" \"c\")))",
         create_builtins_module())
     # then
     self.assertEqual([1, WSymbol.get('a'), 'a'], result)
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:map_tests.py

示例9: test_str_strings_are_unchanged

 def test_str_strings_are_unchanged(self):
     # when
     result = eval_str("(str \"123\")", create_builtins_module())
     # then
     self.assertIsInstance(result, WString)
     self.assertIsInstance(result.value, str)
     self.assertEqual("123", result)
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:w_str_tests.py

示例10: test_str_stringifies_quoted_symbols

 def test_str_stringifies_quoted_symbols(self):
     # when
     result = eval_str("(str ''asdf)", create_builtins_module())
     # then
     self.assertIsInstance(result, WString)
     self.assertIsInstance(result.value, str)
     self.assertEqual("'asdf", result)
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:w_str_tests.py

示例11: test_str_stringifies_magic_functions

 def test_str_stringifies_magic_functions(self):
     # when
     result = eval_str("(str str)", create_builtins_module())
     # then
     self.assertIsInstance(result, WString)
     self.assertIsInstance(result.value, str)
     self.assertEqual("str", result)
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:w_str_tests.py

示例12: test_call_nested_macro_returns_empty_list

 def test_call_nested_macro_returns_empty_list(self):
     # when
     result = eval_str("(if true (if true '() 2) 3)",
                       create_builtins_module())
     # then
     self.assertIsInstance(result, WList)
     self.assertEqual([], result)
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:misc_macro_tests.py

示例13: test_get_next_char_after_end_of_stream_raises

 def test_get_next_char_after_end_of_stream_raises(self):
     # expect
     self.assertRaisesRegex(
         Exception,
         "No more characters in the stream.",
         eval_str,
         "(get_next_char (stream \"\"))", create_builtins_module())
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:stream_get_next_char_tests.py

示例14: test_format_interpolates_arguments

 def test_format_interpolates_arguments(self):
     # when
     result = eval_str("(format \"one {} three\" \"two\")",
                       create_builtins_module())
     # then
     self.assertIsInstance(result, WString)
     self.assertEqual("one two three", result)
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:w_format_tests.py

示例15: test_get_next_char_gets_next_char

 def test_get_next_char_gets_next_char(self):
     # when
     result = eval_str("(get_next_char (stream \"abc\"))",
                       create_builtins_module())
     # then
     self.assertIsInstance(result, WString)
     self.assertEqual("a", result)
开发者ID:izrik,项目名称:wodehouse,代码行数:7,代码来源:stream_get_next_char_tests.py


注:本文中的modules.builtins.create_builtins_module函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。