本文整理汇总了Python中a.b方法的典型用法代码示例。如果您正苦于以下问题:Python a.b方法的具体用法?Python a.b怎么用?Python a.b使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类a
的用法示例。
在下文中一共展示了a.b方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_from_custom
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_import_from_custom(self):
import __builtin__
try:
class foo(object):
b = 'abc'
def __import__(name, globals, locals, fromlist):
global received
received = name, fromlist
return foo()
saved = __builtin__.__import__
__builtin__.__import__ = __import__
from a import b
self.assertEqual(received, ('a', ('b', )))
finally:
__builtin__.__import__ = saved
示例2: test_import_from_custom
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_import_from_custom(self):
import builtins
try:
class foo(object):
b = 'abc'
def __import__(name, globals, locals, fromlist, level):
global received
received = name, fromlist
return foo()
saved = builtins.__import__
builtins.__import__ = __import__
from a import b
self.assertEqual(received, ('a', ('b', )))
finally:
builtins.__import__ = saved
示例3: test_size_if_else
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_size_if_else():
example = """
@identity
class Foo(object):
@identity
@identity
def bar(self):
if "a" == "b":
pass
elif "b" == "c":
pass
else:
pass
"""
size = 11
check_size(example, size)
示例4: test_dotted
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_dotted(self):
self.assertEqual(self.parse("""
import a.b
"""), [parsepy.ImportStatement(name='a.b')])
示例5: test_as
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_as(self):
self.assertEqual(self.parse("""
import a as b
"""), [parsepy.ImportStatement(name='a', new_name='b')])
示例6: test_dotted_as
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_dotted_as(self):
self.assertEqual(self.parse("""
import a.b as c
"""), [parsepy.ImportStatement(name='a.b', new_name='c')])
示例7: test_dotted_comma
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_dotted_comma(self):
self.assertEqual(self.parse("""
import a.b, c
"""), [parsepy.ImportStatement(name='a.b'),
parsepy.ImportStatement(name='c')])
示例8: test_multiple_1
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_multiple_1(self):
self.assertEqual(self.parse("""
import a, b, c, d
"""), [parsepy.ImportStatement(name='a'),
parsepy.ImportStatement(name='b'),
parsepy.ImportStatement(name='c'),
parsepy.ImportStatement(name='d')])
示例9: test_multiple_3
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_multiple_3(self):
self.assertEqual(self.parse("""
import a, b as bb, a.x, a.x.y as a_x_y
"""), [parsepy.ImportStatement(name='a'),
parsepy.ImportStatement(name='b', new_name='bb'),
parsepy.ImportStatement(name='a.x', new_name='a.x'),
parsepy.ImportStatement(name='a.x.y', new_name='a_x_y'),
])
示例10: test_multiple_4
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_multiple_4(self):
self.assertEqual(self.parse("""
import a
import b
import c
import d
"""), [parsepy.ImportStatement(name='a'),
parsepy.ImportStatement(name='b'),
parsepy.ImportStatement(name='c'),
parsepy.ImportStatement(name='d')])
示例11: test_from
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_from(self):
self.assertEqual(self.parse("""
from a import b
"""), [parsepy.ImportStatement(name='a.b', new_name='b', is_from=True)])
示例12: test_from_with_rename
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_from_with_rename(self):
self.assertEqual(self.parse("""
from a import b as c
"""), [parsepy.ImportStatement(name='a.b', new_name='c', is_from=True)])
示例13: test_dotted_from
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_dotted_from(self):
self.assertEqual(self.parse("""
from a.b.c import d as e
"""), [parsepy.ImportStatement(name='a.b.c.d', new_name='e', is_from=True)])
示例14: test_from_parentheses
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_from_parentheses(self):
self.assertEqual(self.parse("""
from a import (b, c, d as dd)
"""), [parsepy.ImportStatement(name='a.b', new_name='b', is_from=True),
parsepy.ImportStatement(name='a.c', new_name='c', is_from=True),
parsepy.ImportStatement(name='a.d', new_name='dd', is_from=True)])
示例15: test_asterisk
# 需要导入模块: import a [as 别名]
# 或者: from a import b [as 别名]
def test_asterisk(self):
self.assertEqual(self.parse("""
from a import *
from a.b import *
from a . b . c import *
"""), [parsepy.ImportStatement(name='a', is_from=True, is_star=True),
parsepy.ImportStatement(name='a.b', is_from=True, is_star=True),
parsepy.ImportStatement(
name='a.b.c', is_from=True, is_star=True)])