Skip to content

Commit

Permalink
Implement new codemod API
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Jan 16, 2024
1 parent a69a7ff commit cafb824
Show file tree
Hide file tree
Showing 154 changed files with 2,391 additions and 2,101 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source = codemodder
omit =
*/codemodder/scripts/*
*/codemodder/_version.py
*/core_codemods/refactor/*

[paths]
codemodder =
Expand Down
20 changes: 14 additions & 6 deletions integration_tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ def setup_class(cls):

def setup_method(self):
try:
self.codemod_wrapper = self.codemod_registry.match_codemods(
codemod_include=[self.codemod.name()]
name = (
self.codemod().name
if isinstance(self.codemod, type)
else self.codemod.name
)
# This is how we ensure that the codemod is actually in the registry
self.codemod_instance = self.codemod_registry.match_codemods(
codemod_include=[name]
)[0]
except IndexError as exc:
raise IndexError(
Expand All @@ -77,16 +83,18 @@ def _assert_run_fields(self, run, output_path):
assert run["elapsed"] != ""
assert (
run["commandLine"]
== f"codemodder {SAMPLES_DIR} --output {output_path} --codemod-include={self.codemod_wrapper.name} --path-include={self.code_path}"
== f"codemodder {SAMPLES_DIR} --output {output_path} --codemod-include={self.codemod_instance.name} --path-include={self.code_path}"
)
assert run["directory"] == os.path.abspath(SAMPLES_DIR)
assert run["sarifs"] == []

def _assert_results_fields(self, results, output_path):
assert len(results) == 1
result = results[0]
assert result["codemod"] == self.codemod_wrapper.id
assert result["references"] == self.codemod_wrapper.references
assert result["codemod"] == self.codemod_instance.id
assert result["references"] == [
ref.to_json() for ref in self.codemod_instance.references
]

# TODO: once we add description for each url.
for reference in result["references"]:
Expand Down Expand Up @@ -147,7 +155,7 @@ def test_file_rewritten(self):
SAMPLES_DIR,
"--output",
self.output_path,
f"--codemod-include={self.codemod_wrapper.name}",
f"--codemod-include={self.codemod_instance.name}",
f"--path-include={self.code_path}",
]

Expand Down
7 changes: 5 additions & 2 deletions integration_tests/test_add_requests_timeout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from core_codemods.add_requests_timeouts import AddRequestsTimeouts
from core_codemods.add_requests_timeouts import (
AddRequestsTimeouts,
TransformAddRequestsTimeouts,
)
from integration_tests.base_test import (
BaseIntegrationTest,
original_and_expected_from_code_path,
Expand Down Expand Up @@ -33,4 +36,4 @@ class TestAddRequestsTimeouts(BaseIntegrationTest):

num_changes = 2
expected_line_change = "3"
change_description = AddRequestsTimeouts.CHANGE_DESCRIPTION
change_description = TransformAddRequestsTimeouts.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_combine_startswith_endswith.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class TestCombineStartswithEndswith(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -1,3 +1,3 @@\n x = \'foo\'\n-if x.startswith("foo") or x.startswith("bar"):\n+if x.startswith(("foo", "bar")):\n print("Yes")\n'
expected_line_change = "2"
change_description = CombineStartswithEndswith.CHANGE_DESCRIPTION
change_description = CombineStartswithEndswith.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_django_debug_flag_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class TestDjangoDebugFlagFlip(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -23,7 +23,7 @@\n SECRET_KEY = "django-insecure-t*rrda&qd4^#q+50^%q^rrsp-t$##&u5_#=9)&@ei^ppl6$*c*"\n \n # SECURITY WARNING: don\'t run with debug turned on in production!\n-DEBUG = True\n+DEBUG = False\n \n ALLOWED_HOSTS = []\n \n'
expected_line_change = "26"
change_description = DjangoDebugFlagOn.CHANGE_DESCRIPTION
change_description = DjangoDebugFlagOn.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_django_json_response_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ class TestDjangoJsonResponseType(BaseIntegrationTest):
# fmt: on

expected_line_change = "6"
change_description = DjangoJsonResponseType.CHANGE_DESCRIPTION
change_description = DjangoJsonResponseType.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_django_receiver_on_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class TestDjangoReceiverOnTop(BaseIntegrationTest):
# fmt: on

expected_line_change = "7"
change_description = DjangoReceiverOnTop.CHANGE_DESCRIPTION
change_description = DjangoReceiverOnTop.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_django_session_cookie_secure_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class TestDjangoSessionCookieSecureOff(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -121,3 +121,4 @@\n # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field\n \n DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"\n+SESSION_COOKIE_SECURE = True\n'
expected_line_change = "124"
change_description = DjangoSessionCookieSecureOff.CHANGE_DESCRIPTION
change_description = DjangoSessionCookieSecureOff.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_exception_without_raise.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class TestExceptionWithoutRaise(BaseIntegrationTest):
# fmt: on

expected_line_change = "2"
change_description = ExceptionWithoutRaise.CHANGE_DESCRIPTION
change_description = ExceptionWithoutRaise.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_file_resource_leak.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class TestFileResourceLeak(BaseIntegrationTest):
# fmt: on

expected_line_change = "3"
change_description = FileResourceLeak.CHANGE_DESCRIPTION
change_description = FileResourceLeak.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_fix_deprecated_logging_warn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class TestFixDeprecatedLoggingWarn(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -1,4 +1,4 @@\n import logging\n \n log = logging.getLogger("my logger")\n-log.warn("hello")\n+log.warning("hello")\n'
expected_line_change = "4"
change_description = FixDeprecatedLoggingWarn.CHANGE_DESCRIPTION
change_description = FixDeprecatedLoggingWarn.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_fix_mutable_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def baz(x=None, y=None):
expected_diff = '--- \n+++ \n@@ -1,4 +1,5 @@\n-def foo(x, y=[]):\n+def foo(x, y=None):\n+ y = [] if y is None else y\n y.append(x)\n print(y)\n \n@@ -7,6 +8,8 @@\n print(x)\n \n \n-def baz(x={"foo": 42}, y=set()):\n+def baz(x=None, y=None):\n+ x = {"foo": 42} if x is None else x\n+ y = set() if y is None else y\n print(x)\n print(y)\n'
expected_line_change = 1
num_changes = 2
change_description = FixMutableParams.CHANGE_DESCRIPTION
change_description = FixMutableParams.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_flask_json_response_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ class TestFlaskJsonResponseType(BaseIntegrationTest):
# fmt: on

expected_line_change = "9"
change_description = FlaskJsonResponseType.CHANGE_DESCRIPTION
change_description = FlaskJsonResponseType.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_harden_pyyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class TestHardenPyyaml(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -1,4 +1,4 @@\n import yaml\n \n data = b"!!python/object/apply:subprocess.Popen \\\\n- ls"\n-deserialized_data = yaml.load(data, Loader=yaml.Loader)\n+deserialized_data = yaml.load(data, Loader=yaml.SafeLoader)\n'
expected_line_change = "4"
change_description = HardenPyyaml.CHANGE_DESCRIPTION
change_description = HardenPyyaml.change_description
# expected exception because the yaml.SafeLoader protects against unsafe code
allowed_exceptions = (yaml.constructor.ConstructorError,)
2 changes: 1 addition & 1 deletion integration_tests/test_harden_ruamel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class TestHardenRuamel(BaseIntegrationTest):
expected_diff = '--- \n+++ \n@@ -1,4 +1,4 @@\n from ruamel.yaml import YAML\n \n-serializer = YAML(typ="unsafe")\n-serializer = YAML(typ="base")\n+serializer = YAML(typ="safe")\n+serializer = YAML(typ="safe")\n'
expected_line_change = "3"
num_changes = 2
change_description = HardenRuamel.CHANGE_DESCRIPTION
change_description = HardenRuamel.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_https_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class TestHTTPSConnection(BaseIntegrationTest):
expected_diff = '--- \n+++ \n@@ -1,8 +1,7 @@\n import urllib3\n import urllib3.connectionpool as pool\n-from urllib3 import HTTPConnectionPool as something\n \n-urllib3.HTTPConnectionPool("localhost", "80")\n-urllib3.connectionpool.HTTPConnectionPool("localhost", "80")\n-something("localhost", "80")\n-pool.HTTPConnectionPool("localhost", "80")\n+urllib3.HTTPSConnectionPool("localhost", "80")\n+urllib3.connectionpool.HTTPSConnectionPool("localhost", "80")\n+urllib3.HTTPSConnectionPool("localhost", "80")\n+pool.HTTPSConnectionPool("localhost", "80")\n'
expected_line_change = "5"
num_changes = 4
change_description = HTTPSConnection.CHANGE_DESCRIPTION
change_description = HTTPSConnection.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_jinja2_autoescape.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class TestEnableJinja2Autoescape(BaseIntegrationTest):
expected_diff = "--- \n+++ \n@@ -1,4 +1,4 @@\n from jinja2 import Environment\n \n-env = Environment()\n-env = Environment(autoescape=False)\n+env = Environment(autoescape=True)\n+env = Environment(autoescape=True)\n"
expected_line_change = "3"
num_changes = 2
change_description = EnableJinja2Autoescape.CHANGE_DESCRIPTION
change_description = EnableJinja2Autoescape.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_jwt_decode_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class TestJwtDecodeVerify(BaseIntegrationTest):
expected_diff = '--- \n+++ \n@@ -8,7 +8,7 @@\n \n encoded_jwt = jwt.encode(payload, SECRET_KEY, algorithm="HS256")\n \n-decoded_payload = jwt.decode(encoded_jwt, SECRET_KEY, algorithms=["HS256"], verify=False)\n-decoded_payload = jwt.decode(encoded_jwt, SECRET_KEY, algorithms=["HS256"], options={"verify_signature": False})\n+decoded_payload = jwt.decode(encoded_jwt, SECRET_KEY, algorithms=["HS256"], verify=True)\n+decoded_payload = jwt.decode(encoded_jwt, SECRET_KEY, algorithms=["HS256"], options={"verify_signature": True})\n \n var = "something"\n'
expected_line_change = "11"
num_changes = 2
change_description = JwtDecodeVerify.CHANGE_DESCRIPTION
change_description = JwtDecodeVerify.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_limit_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class TestLimitReadline(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -1,2 +1,2 @@\n file = open("some_file.txt")\n-file.readline()\n+file.readline(5_000_000)\n'
expected_line_change = "2"
change_description = LimitReadline.CHANGE_DESCRIPTION
change_description = LimitReadline.change_description
# expected because output code points to fake file
allowed_exceptions = (FileNotFoundError,)
2 changes: 1 addition & 1 deletion integration_tests/test_literal_or_new_object_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class TestLiteralOrNewObjectIdentity(BaseIntegrationTest):
# fmt: on

expected_line_change = "2"
change_description = LiteralOrNewObjectIdentity.CHANGE_DESCRIPTION
change_description = LiteralOrNewObjectIdentity.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_lxml_safe_parser_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class TestLxmlSafeParserDefaults(BaseIntegrationTest):
)
expected_diff = "--- \n+++ \n@@ -1,2 +1,2 @@\n import lxml.etree\n-parser = lxml.etree.XMLParser()\n+parser = lxml.etree.XMLParser(resolve_entities=False)\n"
expected_line_change = "2"
change_description = LxmlSafeParserDefaults.CHANGE_DESCRIPTION
change_description = LxmlSafeParserDefaults.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_lxml_safe_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ class TestLxmlSafeParsing(BaseIntegrationTest):
expected_diff = '--- \n+++ \n@@ -1,3 +1,3 @@\n import lxml.etree\n-lxml.etree.parse("path_to_file")\n-lxml.etree.fromstring("xml_str")\n+lxml.etree.parse("path_to_file", parser=lxml.etree.XMLParser(resolve_entities=False))\n+lxml.etree.fromstring("xml_str", parser=lxml.etree.XMLParser(resolve_entities=False))\n'
expected_line_change = "2"
num_changes = 2
change_description = LxmlSafeParsing.CHANGE_DESCRIPTION
change_description = LxmlSafeParsing.change_description
allowed_exceptions = (OSError,)
2 changes: 1 addition & 1 deletion integration_tests/test_numpy_nan_equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ class TestNumpyNanEquality(BaseIntegrationTest):
# fmt: on

expected_line_change = "4"
change_description = NumpyNanEquality.CHANGE_DESCRIPTION
change_description = NumpyNanEquality.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_order_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class TestOrderImports(BaseIntegrationTest):

expected_diff = "--- \n+++ \n@@ -1,20 +1,14 @@\n #!/bin/env python\n-from abc import ABCMeta\n-\n+# comment builtins4\n+# comment builtins5\n+# comment builtins3\n # comment builtins1\n # comment builtins2\n import builtins\n-\n+import collections\n+import datetime\n # comment a\n-from abc import ABC\n-\n-# comment builtins3\n-import builtins, datetime\n-\n-# comment builtins4\n-# comment builtins5\n-import builtins\n-import collections\n+from abc import ABC, ABCMeta\n \n ABC\n ABCMeta\n"
expected_line_change = "2"
change_description = OrderImports.CHANGE_DESCRIPTION
change_description = OrderImports.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_process_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestProcessSandbox(BaseIntegrationTest):
expected_line_change = "3"
num_changes = 4
num_changed_files = 2
change_description = ProcessSandbox.CHANGE_DESCRIPTION
change_description = ProcessSandbox.change_description

requirements_path = "tests/samples/requirements.txt"
original_requirements = "# file used to test dependency management\nrequests==2.31.0\nblack==23.7.*\nmypy~=1.4\npylint>1\n"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_remove_debug_breakpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class TestRemoveDebugBreakpoint(BaseIntegrationTest):
'--- \n+++ \n@@ -1,3 +1,2 @@\n print("hello")\n-breakpoint()\n print("world")\n'
)
expected_line_change = "2"
change_description = RemoveDebugBreakpoint.CHANGE_DESCRIPTION
change_description = RemoveDebugBreakpoint.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_remove_future_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class TestRemoveFutureImports(BaseIntegrationTest):

num_changes = 2
expected_line_change = "1"
change_description = RemoveFutureImports.CHANGE_DESCRIPTION
change_description = RemoveFutureImports.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_remove_module_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class TestRemoveModuleGlobal(BaseIntegrationTest):
""".lstrip()
expected_diff = '--- \n+++ \n@@ -1,4 +1,3 @@\n price = 25\n print("hello")\n-global price\n price = 30\n'
expected_line_change = "3"
change_description = RemoveModuleGlobal.CHANGE_DESCRIPTION
change_description = RemoveModuleGlobal.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_remove_unused_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class TestRemoveUnusedImports(BaseIntegrationTest):

expected_diff = "--- \n+++ \n@@ -1,5 +1,5 @@\n import abc\n-from builtins import complex, dict\n+from builtins import complex\n \n abc\n complex\n"
expected_line_change = 2
change_description = RemoveUnusedImports.CHANGE_DESCRIPTION
change_description = RemoveUnusedImports.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_request_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ class TestRequestsVerify(BaseIntegrationTest):
expected_diff = '--- \n+++ \n@@ -1,5 +1,5 @@\n import requests\n \n-requests.get("https://www.google.com", verify=False)\n-requests.post("https://some-api/", json={"id": 1234, "price": 18}, verify=False)\n+requests.get("https://www.google.com", verify=True)\n+requests.post("https://some-api/", json={"id": 1234, "price": 18}, verify=True)\n var = "hello"\n'
expected_line_change = "3"
num_changes = 2
change_description = RequestsVerify.CHANGE_DESCRIPTION
change_description = RequestsVerify.change_description
# expected because when executing the output code it will make a request which fails, which is OK.
allowed_exceptions = (exceptions.ConnectionError,)
2 changes: 1 addition & 1 deletion integration_tests/test_secure_flask_cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class TestSecureFlaskCookie(BaseIntegrationTest):
)
expected_diff = "--- \n+++ \n@@ -5,5 +5,5 @@\n @app.route('/')\n def index():\n resp = make_response('Custom Cookie Set')\n- resp.set_cookie('custom_cookie', 'value')\n+ resp.set_cookie('custom_cookie', 'value', secure=True, httponly=True, samesite='Lax')\n return resp\n"
expected_line_change = "8"
change_description = SecureFlaskCookie.CHANGE_DESCRIPTION
change_description = SecureFlaskCookie.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_secure_flask_session_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class TestSecureFlaskSessionConfig(BaseIntegrationTest):
)
expected_diff = "--- \n+++ \n@@ -1,6 +1,6 @@\n from flask import Flask\n app = Flask(__name__)\n-app.config['SESSION_COOKIE_HTTPONLY'] = False\n+app.config['SESSION_COOKIE_HTTPONLY'] = True\n @app.route('/')\n def hello_world():\n return 'Hello World!'\n"
expected_line_change = "3"
change_description = SecureFlaskSessionConfig.CHANGE_DESCRIPTION
change_description = SecureFlaskSessionConfig.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_secure_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class TestSecureRandom(BaseIntegrationTest):

expected_diff = '--- \n+++ \n@@ -1,4 +1,4 @@\n-import random\n+import secrets\n \n-random.random()\n+secrets.SystemRandom().random()\n var = "hello"\n'
expected_line_change = "3"
change_description = SecureRandom.CHANGE_DESCRIPTION
change_description = SecureRandom.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_sql_parameterization.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ class TestSQLQueryParameterization(BaseIntegrationTest):
# fmt: on

expected_line_change = "12"
change_description = SQLQueryParameterization.CHANGE_DESCRIPTION
change_description = SQLQueryParameterization.change_description
num_changed_files = 1
2 changes: 1 addition & 1 deletion integration_tests/test_subprocess_shell_false.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class TestSubprocessShellFalse(BaseIntegrationTest):
)
expected_diff = "--- \n+++ \n@@ -1,2 +1,2 @@\n import subprocess\n-subprocess.run(\"echo 'hi'\", shell=True)\n+subprocess.run(\"echo 'hi'\", shell=False)\n"
expected_line_change = "2"
change_description = SubprocessShellFalse.CHANGE_DESCRIPTION
change_description = SubprocessShellFalse.change_description
# expected because output code points to fake file
allowed_exceptions = (FileNotFoundError,)
2 changes: 1 addition & 1 deletion integration_tests/test_tempfile_mktemp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class TestTempfileMktemp(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -1,4 +1,4 @@\n import tempfile\n \n-tempfile.mktemp()\n+tempfile.mkstemp()\n var = "hello"\n'
expected_line_change = "3"
change_description = TempfileMktemp.CHANGE_DESCRIPTION
change_description = TempfileMktemp.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_unnecessary_f_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class TestFStr(BaseIntegrationTest):
)
expected_diff = '--- \n+++ \n@@ -1,2 +1,2 @@\n-bad = f"hello"\n+bad = "hello"\n good = f"{2+3}"\n'
expected_line_change = "1"
change_description = RemoveUnnecessaryFStr.CHANGE_DESCRIPTION
change_description = RemoveUnnecessaryFStr.change_description
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class TestUpgradeSSLContextMininumVersion(BaseIntegrationTest):

expected_diff = '--- \n+++ \n@@ -1,8 +1,9 @@\n from ssl import PROTOCOL_TLS_CLIENT, SSLContext, TLSVersion\n+import ssl\n \n my_ctx = SSLContext(protocol=PROTOCOL_TLS_CLIENT)\n \n print("FOO")\n \n my_ctx.maximum_version = TLSVersion.MAXIMUM_SUPPORTED\n-my_ctx.minimum_version = TLSVersion.TLSv1_1\n+my_ctx.minimum_version = ssl.TLSVersion.TLSv1_2\n'
expected_line_change = "8"
change_description = UpgradeSSLContextMinimumVersion.CHANGE_DESCRIPTION
change_description = UpgradeSSLContextMinimumVersion.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_upgrade_sslcontext_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class TestUpgradeWeakTLS(BaseIntegrationTest):
expected_new_code = "import ssl\n\nssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n"
expected_diff = "--- \n+++ \n@@ -1,3 +1,3 @@\n import ssl\n \n-ssl.SSLContext(ssl.PROTOCOL_SSLv2)\n+ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n"
expected_line_change = "3"
change_description = UpgradeSSLContextTLS.CHANGE_DESCRIPTION
change_description = UpgradeSSLContextTLS.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_url_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TestUrlSandbox(BaseIntegrationTest):
"""

expected_line_change = "5"
change_description = UrlSandbox.CHANGE_DESCRIPTION
change_description = UrlSandbox.change_description
num_changed_files = 2

requirements_path = "tests/samples/requirements.txt"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_use_defusedxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestUseDefusedXml(BaseIntegrationTest):
"""

expected_line_change = "5"
change_description = UseDefusedXml.CHANGE_DESCRIPTION
change_description = UseDefusedXml.change_description

requirements_path = "tests/samples/requirements.txt"
original_requirements = "# file used to test dependency management\nrequests==2.31.0\nblack==23.7.*\nmypy~=1.4\npylint>1\n"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_use_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class TestUseGenerator(BaseIntegrationTest):
"""

expected_line_change = "6"
change_description = UseGenerator.CHANGE_DESCRIPTION
change_description = UseGenerator.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_use_set_literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class TestUseSetLiteral(BaseIntegrationTest):

expected_line_change = "1"
num_changes = 2
change_description = UseSetLiteral.CHANGE_DESCRIPTION
change_description = UseSetLiteral.change_description
2 changes: 1 addition & 1 deletion integration_tests/test_use_walrus_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def whatever():

num_changes = 3
expected_line_change = 1
change_description = UseWalrusIf.CHANGE_DESCRIPTION
change_description = UseWalrusIf.change_description
Loading

0 comments on commit cafb824

Please sign in to comment.