Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR Remove 'only_for' decorator for all python versions less than 3.7 #593

Merged
merged 4 commits into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion ropetest/codeanalyzetest.py
Expand Up @@ -734,7 +734,6 @@ def afunc():
found_pyname = name_finder.get_pyname_at(code.index("afunc") + 1)
self.assertEqual(afunc.get_object(), found_pyname.get_object())

@testutils.only_for("2.5")
def test_relative_modules_after_from_statements(self):
pkg1 = testutils.create_package(self.project, "pkg1")
pkg2 = testutils.create_package(self.project, "pkg2", pkg1)
Expand Down
7 changes: 0 additions & 7 deletions ropetest/pycoretest.py
Expand Up @@ -569,7 +569,6 @@ def f(self):
c_class = pymod["C"].get_object()
self.assertFalse("var1" in c_class)

@testutils.only_for("2.5")
def test_with_statement_variables(self):
code = dedent("""\
import threading
Expand All @@ -580,7 +579,6 @@ def test_with_statement_variables(self):
pymod = libutils.get_string_module(self.project, code)
self.assertTrue("var" in pymod)

@testutils.only_for("2.5")
def test_with_statement_variables_and_tuple_assignment(self):
code = dedent("""\
class A(object):
Expand All @@ -596,7 +594,6 @@ def __exit__(self, type, value, tb):
self.assertTrue("a" in pymod)
self.assertTrue("b" in pymod)

@testutils.only_for("2.5")
def test_with_statement_variable_type(self):
code = dedent("""\
class A(object):
Expand All @@ -614,7 +611,6 @@ def __exit__(self, type, value, tb):
var = pymod["var"].get_object()
self.assertEqual(a_class, var.get_type())

@testutils.only_for("2.7")
def test_nested_with_statement_variable_type(self):
code = dedent("""\
class A(object):
Expand All @@ -641,7 +637,6 @@ def __exit__(self, type, value, tb):
var_b = pymod["var_b"].get_object()
self.assertEqual(b_class, var_b.get_type())

@testutils.only_for("2.5")
def test_with_statement_with_no_vars(self):
code = dedent("""\
with open("file"): pass
Expand Down Expand Up @@ -1131,7 +1126,6 @@ def test_relative_imports_for_string_scopes(self):
mod2_scope = libutils.get_string_scope(self.project, mod2.read(), mod2)
self.assertEqual(mod1_object, mod2_scope["mod1"].get_object())

@testutils.only_for("2.5")
def test_new_style_relative_imports(self):
pkg = testutils.create_package(self.project, "pkg")
mod1 = testutils.create_module(self.project, "mod1", pkg)
Expand All @@ -1141,7 +1135,6 @@ def test_new_style_relative_imports(self):
mod2_object = self.pycore.resource_to_pyobject(mod2)
self.assertEqual(mod1_object, mod2_object["mod1"].get_object())

@testutils.only_for("2.5")
def test_new_style_relative_imports2(self):
pkg = testutils.create_package(self.project, "pkg")
mod1 = testutils.create_module(self.project, "mod1")
Expand Down
1 change: 0 additions & 1 deletion ropetest/pyscopestest.py
Expand Up @@ -407,7 +407,6 @@ def f(a):
inner_scope = scope.get_scopes()[0]
self.assertEqual(inner_scope, scope.get_inner_scope_for_offset(10))

@testutils.only_for("3.5")
def test_get_scope_for_offset_for_function_scope_and_async_with_statement(self):
scope = libutils.get_string_scope(
self.project,
Expand Down
1 change: 0 additions & 1 deletion ropetest/refactor/extracttest.py
Expand Up @@ -110,7 +110,6 @@ def extracted():
""")
self.assertEqual(expected, refactored)

@testutils.only_for("3.5")
def test_extract_function_containing_dict_generalized_unpacking(self):
code = dedent("""\
def a_func(dict1):
Expand Down
2 changes: 0 additions & 2 deletions ropetest/refactor/importutilstest.py
Expand Up @@ -107,7 +107,6 @@ def test_get_import_statements_for_from_star(self):
"from pkg1 import *", imports[0].import_info.get_import_statement()
)

@testutils.only_for("2.5")
def test_get_import_statements_for_new_relatives(self):
self.mod2.write("from .mod3 import x\n")
pymod = self.project.get_module("pkg2.mod2")
Expand Down Expand Up @@ -932,7 +931,6 @@ def a_func():
self.import_tools.relatives_to_absolutes(pymod),
)

@testutils.only_for("2.5")
def test_transform_rel_imports_to_abs_imports_for_new_relatives(self):
self.mod3.write(dedent("""\
def a_func():
Expand Down
19 changes: 1 addition & 18 deletions ropetest/refactor/patchedasttest.py
Expand Up @@ -268,7 +268,7 @@ def test_handling_format_strings_with_implicit_join(self):
checker = _ResultChecker(self, ast_frag)
checker.check_children(
"JoinedStr",
["rf'", "abc", "FormattedValue", '\' f"""xxx', "FormattedValue", " ", '"""',],
["rf'", "abc", "FormattedValue", '\' f"""xxx', "FormattedValue", " ", '"""'],
)
checker.check_children("FormattedValue", ["{", "", "Name", "", "}"])

Expand Down Expand Up @@ -418,7 +418,6 @@ def test_call_func_and_star_args(self):
"Call", ["Name", "", "(", "", "Num", "", ",", " ", "*", "", "Name", "", ")"]
)

@testutils.only_for("3.5")
def test_call_func_and_star_argspython35(self):
source = "f(1, *args)\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -434,7 +433,6 @@ def test_call_func_and_only_dstar_args(self):
checker = _ResultChecker(self, ast_frag)
checker.check_children("Call", ["Name", "", "(", "", "**", "", "Name", "", ")"])

@testutils.only_for("3.5")
def test_call_func_and_only_dstar_args_python35(self):
source = "f(**kwds)\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -451,7 +449,6 @@ def test_call_func_and_both_varargs_and_kwargs(self):
["Name", "", "(", "", "*", "", "Name", "", ",", " ", "**", "", "Name", "", ")"],
)

@testutils.only_for("3.5")
def test_call_func_and_both_varargs_and_kwargs_python35(self):
source = "f(*args, **kwds)\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand Down Expand Up @@ -515,7 +512,6 @@ def f():
["@", "", "Name", "\n", "def", " ", "f", "", "(", "", "arguments", "", ")", "", ":", "\n ", "Pass"],
)

@testutils.only_for("2.6")
def test_decorators_for_classes(self):
source = dedent("""\
@d
Expand Down Expand Up @@ -611,7 +607,6 @@ def test_dict_node(self):
["{", "", "Num", "", ":", " ", "Num", "", ",", " ", "Num", "", ":", " ", "Num", "", "}"],
)

@testutils.only_for("3.5")
def test_dict_node_with_unpacking(self):
source = "{**dict1, **dict2}\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand Down Expand Up @@ -712,7 +707,6 @@ def test_normal_from_node(self):
)
checker.check_children("alias", ["y"])

@testutils.only_for("2.5")
def test_from_node(self):
source = "from ..x import y as z\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -723,7 +717,6 @@ def test_from_node(self):
)
checker.check_children("alias", ["y", " ", "as", " ", "z"])

@testutils.only_for("2.5")
def test_from_node_relative_import(self):
source = "from . import y as z\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -734,7 +727,6 @@ def test_from_node_relative_import(self):
)
checker.check_children("alias", ["y", " ", "as", " ", "z"])

@testutils.only_for("2.5")
def test_from_node_whitespace_around_dots_1(self):
source = "from . . . import y as z\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -745,7 +737,6 @@ def test_from_node_whitespace_around_dots_1(self):
)
checker.check_children("alias", ["y", " ", "as", " ", "z"])

@testutils.only_for("2.5")
def test_from_node_whitespace_around_dots_2(self):
source = "from . a . b import y as z\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand Down Expand Up @@ -1171,7 +1162,6 @@ def test_while_node(self):
["while", " ", NameConstant, "", ":", "\n ", "Pass", "\n", "else", "", ":", "\n ", "Pass"],
)

@testutils.only_for("2.5")
def test_with_node(self):
source = dedent("""\
from __future__ import with_statement
Expand All @@ -1185,7 +1175,6 @@ def test_with_node(self):
["with", " ", "Name", " ", "as", " ", "Name", "", ":", "\n ", "Pass"],
)

@testutils.only_for("3.5")
def test_async_with_node(self):
source = dedent("""\
async def afunc():
Expand Down Expand Up @@ -1251,7 +1240,6 @@ def test_try_except_node__with_as_syntax(self):
["except", " ", "Name", " ", "as", " ", expected_child, "", ":", "\n ", "Pass"],
)

@testutils.only_for("2.5")
def test_try_except_and_finally_node(self):
source = dedent("""\
try:
Expand Down Expand Up @@ -1297,7 +1285,6 @@ def test_semicolon(self):
source = "1;\n"
patchedast.get_patched_ast(source, True)

@testutils.only_for("2.5")
def test_if_exp_node(self):
source = "1 if True else 2\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand Down Expand Up @@ -1342,7 +1329,6 @@ def test_starargs_after_keywords_legacy(self):
["Name", "", "(", "", "keyword", "", ",", " ", "*", "", "Name", "", ")"],
)

@testutils.only_for("3.5")
def test_starargs_before_keywords(self):
source = "foo(*args, a=1)\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -1351,7 +1337,6 @@ def test_starargs_before_keywords(self):
"Call", ["Name", "", "(", "*", "Starred", "", ",", " ", "keyword", "", ")"]
)

@testutils.only_for("3.5")
def test_starargs_in_keywords(self):
source = "foo(a=1, *args, b=2)\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -1361,7 +1346,6 @@ def test_starargs_in_keywords(self):
["Name", "", "(", "", "keyword", "", ",", " *", "Starred", "", ",", " ", "keyword", "", ")"],
)

@testutils.only_for("3.5")
def test_starargs_in_positional(self):
source = "foo(a, *b, c)\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand All @@ -1371,7 +1355,6 @@ def test_starargs_in_positional(self):
["Name", "", "(", "", "Name", "", ",", " *", "Starred", "", ",", " ", "Name", "", ")"],
)

@testutils.only_for("3.5")
def test_starargs_after_keywords(self):
source = "foo(a=1, *args)\n"
ast_frag = patchedast.get_patched_ast(source, True)
Expand Down
9 changes: 0 additions & 9 deletions ropetest/refactor/renametest.py
Expand Up @@ -305,7 +305,6 @@ def test_renaming_with_backslash_continued_names(self):
)
self.assertEqual("is_replace = True\n'ali'.\\\nreplace\n", refactored)

@testutils.only_for("3.6")
def test_renaming_occurrence_in_f_string(self):
code = dedent("""\
a_var = 20
Expand All @@ -318,7 +317,6 @@ def test_renaming_occurrence_in_f_string(self):
refactored = self._local_rename(code, 2, "new_var")
self.assertEqual(expected, refactored)

@testutils.only_for("3.6")
def test_renaming_occurrence_in_nested_f_string(self):
code = dedent("""\
a_var = 20
Expand All @@ -331,7 +329,6 @@ def test_renaming_occurrence_in_nested_f_string(self):
refactored = self._local_rename(code, 2, "new_var")
self.assertEqual(expected, refactored)

@testutils.only_for("3.6")
def test_not_renaming_string_contents_in_f_string(self):
refactored = self._local_rename(
"a_var = 20\na_string=f'{\"a_var\"}'\n", 2, "new_var"
Expand Down Expand Up @@ -444,7 +441,6 @@ def new_func():
refactored,
)

@testutils.only_for("3.5")
def test_renaming_async_function(self):
code = dedent("""\
async def a_func():
Expand All @@ -459,7 +455,6 @@ async def new_func():
refactored,
)

@testutils.only_for("3.5")
def test_renaming_await(self):
code = dedent("""\
async def b_func():
Expand Down Expand Up @@ -878,7 +873,6 @@ def test_renaming_for_loop_variable(self):
refactored,
)

@testutils.only_for("3.5")
def test_renaming_async_for_loop_variable(self):
code = dedent("""\
async def func():
Expand All @@ -895,7 +889,6 @@ async def func():
refactored,
)

@testutils.only_for("3.5")
def test_renaming_async_with_context_manager(self):
code = dedent("""\
def a_cm(): pass
Expand All @@ -908,7 +901,6 @@ async def a_func():
async with another_cm() as x: pass""")
self.assertEqual(refactored, expected)

@testutils.only_for("3.5")
def test_renaming_async_with_as_variable(self):
code = dedent("""\
async def func():
Expand Down Expand Up @@ -1422,7 +1414,6 @@ def f():
)

# XXX: with variables should not leak
@testutils.only_for("2.5")
def xxx_test_with_statement_variables_should_not_leak(self):
code = dedent("""\
f = 1
Expand Down