• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python warning_tests.inner函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_filename

 def test_filename(self):
     with warnings_state(self.module):
         with original_warnings.catch_warnings(record=True, module=self.module) as w:
             warning_tests.inner("spam1")
             self.assertEqual(os.path.basename(w[-1].filename), "warning_tests.py")
             warning_tests.outer("spam2")
             self.assertEqual(os.path.basename(w[-1].filename), "warning_tests.py")
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:7,代码来源:test_warnings.py


示例2: test_missing_filename_not_main

 def test_missing_filename_not_main(self):
     # If __file__ is not specified and __main__ is not the module name,
     # then __file__ should be set to the module name.
     filename = warning_tests.__file__
     try:
         del warning_tests.__file__
         with warnings_state(self.module):
             with original_warnings.catch_warnings(record=True, module=self.module) as w:
                 warning_tests.inner("spam8", stacklevel=1)
                 self.assertEqual(w[-1].filename, warning_tests.__name__)
     finally:
         warning_tests.__file__ = filename
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:12,代码来源:test_warnings.py


示例3: test_missing_filename_main_with_argv

 def test_missing_filename_main_with_argv(self):
     # If __file__ is not specified and the caller is __main__ and sys.argv
     # exists, then use sys.argv[0] as the file.
     filename = warning_tests.__file__
     module_name = warning_tests.__name__
     try:
         del warning_tests.__file__
         warning_tests.__name__ = "__main__"
         with warnings_state(self.module):
             with original_warnings.catch_warnings(record=True, module=self.module) as w:
                 warning_tests.inner("spam9", stacklevel=1)
                 self.assertEqual(w[-1].filename, sys.argv[0])
     finally:
         warning_tests.__file__ = filename
         warning_tests.__name__ = module_name
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:15,代码来源:test_warnings.py


示例4: test_missing_filename_main_without_argv

 def test_missing_filename_main_without_argv(self):
     # If __file__ is not specified, the caller is __main__, and sys.argv
     # is not set, then '__main__' is the file name.
     filename = warning_tests.__file__
     module_name = warning_tests.__name__
     argv = sys.argv
     try:
         del warning_tests.__file__
         warning_tests.__name__ = "__main__"
         del sys.argv
         with warnings_state(self.module):
             with original_warnings.catch_warnings(record=True, module=self.module) as w:
                 warning_tests.inner("spam10", stacklevel=1)
                 self.assertEqual(w[-1].filename, "__main__")
     finally:
         warning_tests.__file__ = filename
         warning_tests.__name__ = module_name
         sys.argv = argv
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:18,代码来源:test_warnings.py


示例5: test_missing_filename_main_with_argv_empty_string

 def test_missing_filename_main_with_argv_empty_string(self):
     # If __file__ is not specified, the caller is __main__, and sys.argv[0]
     # is the empty string, then '__main__ is the file name.
     # Tests issue 2743.
     file_name = warning_tests.__file__
     module_name = warning_tests.__name__
     argv = sys.argv
     try:
         del warning_tests.__file__
         warning_tests.__name__ = "__main__"
         sys.argv = [""]
         with warnings_state(self.module):
             with original_warnings.catch_warnings(record=True, module=self.module) as w:
                 warning_tests.inner("spam11", stacklevel=1)
                 self.assertEqual(w[-1].filename, "__main__")
     finally:
         warning_tests.__file__ = file_name
         warning_tests.__name__ = module_name
         sys.argv = argv
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:19,代码来源:test_warnings.py


示例6: test_show_warning_output

 def test_show_warning_output(self):
     # With showarning() missing, make sure that output is okay.
     text = "test show_warning"
     with original_warnings.catch_warnings(module=self.module):
         self.module.filterwarnings("always", category=UserWarning)
         del self.module.showwarning
         with test_support.captured_output("stderr") as stream:
             warning_tests.inner(text)
             result = stream.getvalue()
     self.assertEqual(result.count("\n"), 2, "Too many newlines in %r" % result)
     first_line, second_line = result.split("\n", 1)
     expected_file = os.path.splitext(warning_tests.__file__)[0] + ".py"
     first_line_parts = first_line.rsplit(":", 3)
     path, line, warning_class, message = first_line_parts
     line = int(line)
     self.assertEqual(expected_file, path)
     self.assertEqual(warning_class, " " + UserWarning.__name__)
     self.assertEqual(message, " " + text)
     expected_line = "  " + linecache.getline(path, line).strip() + "\n"
     assert expected_line
     self.assertEqual(second_line, expected_line)
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:21,代码来源:test_warnings.py


示例7: test_stacklevel

    def test_stacklevel(self):
        # Test stacklevel argument
        # make sure all messages are different, so the warning won't be skipped
        with warnings_state(self.module):
            with original_warnings.catch_warnings(record=True,
                    module=self.module) as w:
                warning_tests.inner("spam3", stacklevel=1)
                self.assertEqual(os.path.basename(w[-1].filename),
                                    "warning_tests.py")
                warning_tests.outer("spam4", stacklevel=1)
                self.assertEqual(os.path.basename(w[-1].filename),
                                    "warning_tests.py")

                warning_tests.inner("spam5", stacklevel=2)
                self.assertEqual(os.path.basename(w[-1].filename),
                                    "test_warnings.py")
                warning_tests.outer("spam6", stacklevel=2)
                self.assertEqual(os.path.basename(w[-1].filename),
                                    "warning_tests.py")
                warning_tests.outer("spam6.5", stacklevel=3)
                self.assertEqual(os.path.basename(w[-1].filename),
                                    "test_warnings.py")

                warning_tests.inner("spam7", stacklevel=9999)
                self.assertEqual(os.path.basename(w[-1].filename),
                                    "sys")
开发者ID:Logotrop,项目名称:trida,代码行数:26,代码来源:test_warnings.py


示例8: test_show_warning_output

 def test_show_warning_output(self):
     # With showarning() missing, make sure that output is okay.
     text = 'test show_warning'
     with original_warnings.catch_warnings(module=self.module):
         self.module.filterwarnings("always", category=UserWarning)
         del self.module.showwarning
         with support.captured_output('stderr') as stream:
             warning_tests.inner(text)
             result = stream.getvalue()
     self.assertEqual(result.count('\n'), 2,
                          "Too many newlines in %r" % result)
     first_line, second_line = result.split('\n', 1)
     expected_file = warning_tests_py
     first_line_parts = first_line.rsplit(':', 3)
     path, line, warning_class, message = first_line_parts
     line = int(line)
     self.assertEqual(expected_file, path)
     self.assertEqual(warning_class, ' ' + UserWarning.__name__)
     self.assertEqual(message, ' ' + text)
     expected_line = '  ' + linecache.getline(path, line).strip() + '\n'
     assert expected_line
     self.assertEqual(second_line, expected_line)
开发者ID:isaiah,项目名称:jython3,代码行数:22,代码来源:test_warnings.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python warnings._warn函数代码示例发布时间:2022-05-26
下一篇:
Python warning_dialog.warning_dialog函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap