Fix version differences for re.sub

This commit is contained in:
Dave Halter
2018-12-09 12:50:01 +01:00
parent 2c5e2609f3
commit f7442032b2
2 changed files with 23 additions and 5 deletions

View File

@@ -108,11 +108,6 @@ for a in re.finditer('a', 'a'):
#? int()
a.start()
#?
re.sub('a', 'a')
#? str() bytes()
re.sub('a', 'a', 'f')
# -----------------
# ref
# -----------------

View File

@@ -78,3 +78,26 @@ def test_namedtuple_goto_definitions(Script):
assert d1.get_line_code() == "class Foo(tuple):\n"
assert d1.module_path is None
def test_re_sub(Script, environment):
"""
This whole test was taken out of completion/stdlib.py, because of the
version differences.
"""
def run(code):
defs = Script(code).goto_definitions()
return {d.name for d in defs}
names = run("import re; re.sub('a', 'a', 'f')")
if environment.version_info.major == 2:
assert names == {'str', 'unicode'}
else:
assert names == {'str', 'bytes'}
# This param is missing because of overloading.
names = run("import re; re.sub('a', 'a')")
if environment.version_info.major == 2:
assert names == {'str', 'unicode'}
else:
assert names == {'str', 'bytes'}