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


Python Source.getstatementrange方法代码示例

本文整理汇总了Python中py.code.Source.getstatementrange方法的典型用法代码示例。如果您正苦于以下问题:Python Source.getstatementrange方法的具体用法?Python Source.getstatementrange怎么用?Python Source.getstatementrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py.code.Source的用法示例。


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

示例1: test_getstatementrange_within_constructs

# 需要导入模块: from py.code import Source [as 别名]
# 或者: from py.code.Source import getstatementrange [as 别名]
 def test_getstatementrange_within_constructs(self):
     source = Source("""\
         try:
             try: 
                 raise ValueError
             except SomeThing: 
                 pass 
         finally:
             42
     """)
     assert len(source) == 7
     assert source.getstatementrange(0) == (0, 7) 
     assert source.getstatementrange(1) == (1, 5) 
     assert source.getstatementrange(2) == (2, 3)
     assert source.getstatementrange(3) == (1, 5)
     assert source.getstatementrange(4) == (4, 5) 
     assert source.getstatementrange(5) == (0, 7)
     assert source.getstatementrange(6) == (6, 7) 
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:20,代码来源:test_source.py

示例2: test_getstatementrange_within_constructs

# 需要导入模块: from py.code import Source [as 别名]
# 或者: from py.code.Source import getstatementrange [as 别名]
 def test_getstatementrange_within_constructs(self):
     source = Source("""\
         try:
             try:
                 raise ValueError
             except SomeThing:
                 pass
         finally:
             42
     """)
     assert len(source) == 7
     # check all lineno's that could occur in a traceback
     #assert source.getstatementrange(0) == (0, 7)
     #assert source.getstatementrange(1) == (1, 5)
     assert source.getstatementrange(2) == (2, 3)
     assert source.getstatementrange(3) == (3, 4)
     assert source.getstatementrange(4) == (4, 5)
     #assert source.getstatementrange(5) == (0, 7)
     assert source.getstatementrange(6) == (6, 7)
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:21,代码来源:test_source.py

示例3: test_getstatementrange_bug

# 需要导入模块: from py.code import Source [as 别名]
# 或者: from py.code.Source import getstatementrange [as 别名]
 def test_getstatementrange_bug(self):
     source = Source("""\
         try:
             x = (
                y +
                z)
         except:
             pass
     """)
     assert len(source) == 6
     assert source.getstatementrange(2) == (1, 4)
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:13,代码来源:test_source.py

示例4: test_getstatementrange_bug2

# 需要导入模块: from py.code import Source [as 别名]
# 或者: from py.code.Source import getstatementrange [as 别名]
 def test_getstatementrange_bug2(self):
     source = Source("""\
         assert (
             33
             ==
             [
               X(3,
                   b=1, c=2
                ),
             ]
           )
     """)
     assert len(source) == 9
     assert source.getstatementrange(5) == (0, 9)
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:16,代码来源:test_source.py

示例5: test_getstatementrange_bug2

# 需要导入模块: from py.code import Source [as 别名]
# 或者: from py.code.Source import getstatementrange [as 别名]
 def test_getstatementrange_bug2(self):
     py.test.skip("fix me (issue19)")
     source = Source("""\
         assert (
             33
             ==
             [
               X(3,
                   b=1, c=2
                ),
             ]
           )
     """)
     assert len(source) == 9
     assert source.getstatementrange(5) == (0, 9)
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:17,代码来源:test_source.py

示例6: test_getstatementrange_with_syntaxerror_issue7

# 需要导入模块: from py.code import Source [as 别名]
# 或者: from py.code.Source import getstatementrange [as 别名]
 def test_getstatementrange_with_syntaxerror_issue7(self):
     source = Source(":")
     py.test.raises(SyntaxError, lambda: source.getstatementrange(0))
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:5,代码来源:test_source.py

示例7: test_getstatementrange_out_of_bounds_py3

# 需要导入模块: from py.code import Source [as 别名]
# 或者: from py.code.Source import getstatementrange [as 别名]
 def test_getstatementrange_out_of_bounds_py3(self):
     source = Source("if xxx:\n   from .collections import something")
     r = source.getstatementrange(1)
     assert r == (1,2)
开发者ID:Eleanor66613,项目名称:CS249-midterm,代码行数:6,代码来源:test_source.py


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