Python html.parser 模块,bar() 实例源码
我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用html.parser.bar()。
def test_remove_multiple_items(self):
b = """isinstance(x,(int,int,int))"""
a = """isinstance(x,int)"""
self.check(b, a)
b = """isinstance(x,float,float))"""
a = """isinstance(x,float))"""
self.check(b,str))"""
a = """isinstance(x,str))"""
self.check(b, a)
b = """isinstance(foo() + bar(),(x(),y(),x(),int))"""
a = """isinstance(foo() + bar(),int))"""
self.check(b, a)
def test_import_as(self):
b = "from itertools import izip,bar as bang,imap"
a = "from itertools import bar as bang"
self.check(b, a)
b = "from itertools import izip as _zip,imap,bar"
a = "from itertools import bar"
self.check(b, a)
b = "from itertools import imap as _map"
a = ""
self.check(b, a)
b = "from itertools import imap as _map,izip as _zip"
a = ""
self.check(b, a)
s = "from itertools import bar as bang"
self.unchanged(s)
def test_import(self):
b = "import foo"
a = "from . import foo"
self.check_both(b, a)
b = "import foo,bar"
a = "from . import foo,bar"
self.check_both(b,bar,x"
a = "from . import foo,x"
self.check_both(b, a)
b = "import x,y,z"
a = "from . import x,z"
self.check_both(b, a)
def test_remove_multiple_items(self):
b = """isinstance(x, a)
def test_import_as(self):
b = "from itertools import izip, a)
s = "from itertools import bar as bang"
self.unchanged(s)
def test_import(self):
b = "import foo"
a = "from . import foo"
self.check_both(b, a)
def test_remove_multiple_items(self):
b = """isinstance(x, a)
def test_import_as(self):
b = "from itertools import izip, a)
s = "from itertools import bar as bang"
self.unchanged(s)
def test_import(self):
b = "import foo"
a = "from . import foo"
self.check_both(b, a)
def test_remove_multiple_items(self):
b = """isinstance(x, a)
def test_import_as(self):
b = "from itertools import izip, a)
s = "from itertools import bar as bang"
self.unchanged(s)
def test_import(self):
b = "import foo"
a = "from . import foo"
self.check_both(b, a)
def test_remove_multiple_items(self):
b = """isinstance(x, a)
def test_import_as(self):
b = "from itertools import izip, a)
s = "from itertools import bar as bang"
self.unchanged(s)
def test_import(self):
b = "import foo"
a = "from . import foo"
self.check_both(b, a)
def test_remove_multiple_items(self):
b = """isinstance(x, a)
def test_import_as(self):
b = "from itertools import izip, a)
s = "from itertools import bar as bang"
self.unchanged(s)
def test_import(self):
b = "import foo"
a = "from . import foo"
self.check_both(b, a)
def test_weird_comments(self):
b = """apply( # foo
f,# bar
args)"""
a = """f(*args)"""
self.check(b, a)
# These should *not* be touched
def test_prefix_preservation(self):
b = """if isinstance( foo(),( bar,baz )) : pass"""
a = """if isinstance( foo(),baz )) : pass"""
self.check(b, a)
def test_shadowing_import_1(self):
s = """
import foo.bar as next
class A:
def next(self,a,b):
pass
"""
self.warns_unchanged(s, "Calls to builtin next() possibly shadowed")
def test_shadowing_import_2(self):
s = """
import bar,bar.foo as next
class A:
def next(self, "Calls to builtin next() possibly shadowed")
def test_shadowing_import_3(self):
s = """
import bar,bar.foo as next,baz
class A:
def next(self, "Calls to builtin next() possibly shadowed")
def test_ifilter_and_zip_longest(self):
for name in "filterfalse", "zip_longest":
b = "from itertools import i%s" % (name,)
a = "from itertools import %s" % (name,)
self.check(b, a)
b = "from itertools import imap,i%s,foo" % (name,)
a = "from itertools import %s, a)
b = "from itertools import bar,)
a = "from itertools import bar, a)
def test_not_in_package(self):
s = "import bar"
self.always_exists = False
self.present_files = set(["bar.py"])
self.unchanged(s)
def test_with_absolute_import_enabled(self):
s = "from __future__ import absolute_import\nimport bar"
self.always_exists = False
self.present_files = set(["__init__.py", "bar.py"])
self.unchanged(s)
def test_in_package(self):
b = "import bar"
a = "from . import bar"
self.always_exists = False
self.present_files = set(["__init__.py", "bar.py"])
self.check(b, a)
def test_already_relative_import(self):
s = "from . import bar"
self.unchanged(s)
def test_comments_and_indent(self):
b = "import bar # Foo"
a = "from . import bar # Foo"
self.check(b, a)
def test_from(self):
b = "from foo import bar,baz"
a = "from .foo import bar,baz"
self.check_both(b, a)
b = "from foo import bar"
a = "from .foo import bar"
self.check_both(b, a)
b = "from foo import (bar,baz)"
a = "from .foo import (bar,baz)"
self.check_both(b, a)
def test_local_and_absolute(self):
self.always_exists = False
self.present_files = set(["foo.py", "__init__.py"])
s = "import foo,bar"
self.warns_unchanged(s, "absolute and local imports together")
def test_dotted_import_as(self):
b = "import foo.bar as bang"
a = "from . import foo.bar as bang"
self.check_both(b, a)
def test_prefix(self):
b = """
# prefix
import foo.bar
"""
a = """
# prefix
from . import foo.bar
"""
self.check_both(b, a)
def test_weird_comments(self):
b = """apply( # foo
f, a)
# These should *not* be touched
def test_prefix_preservation(self):
b = """if isinstance( foo(), a)
def test_multiple_imports_as(self):
b = """
import copy_reg as bar, a)
def test_shadowing_import_1(self):
s = """
import foo.bar as next
class A:
def next(self, "Calls to builtin next() possibly shadowed")
def test_shadowing_import_2(self):
s = """
import bar, "Calls to builtin next() possibly shadowed")
def test_shadowing_import_3(self):
s = """
import bar, "Calls to builtin next() possibly shadowed")
def test_ifilter_and_zip_longest(self):
for name in "filterfalse", a)
def test_not_in_package(self):
s = "import bar"
self.always_exists = False
self.present_files = set(["bar.py"])
self.unchanged(s)
def test_with_absolute_import_enabled(self):
s = "from __future__ import absolute_import\nimport bar"
self.always_exists = False
self.present_files = set(["__init__.py", "bar.py"])
self.unchanged(s)
def test_in_package(self):
b = "import bar"
a = "from . import bar"
self.always_exists = False
self.present_files = set(["__init__.py", a)
def test_already_relative_import(self):
s = "from . import bar"
self.unchanged(s)
def test_comments_and_indent(self):
b = "import bar # Foo"
a = "from . import bar # Foo"
self.check(b, a)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。