From 66c98ea8579fb29bc54ef3d08fed560a2b5291f2 Mon Sep 17 00:00:00 2001 From: David DE CARVALHO Date: Fri, 4 Oct 2024 17:30:11 +0200 Subject: [PATCH] add test case (to check ISSUE 23) --- .../checks/AvoidGlobalVariableInFunctionCheckTest.java | 4 +++- ...py => avoidGlobalVariableInFunctionNonCompliant.py} | 0 .../avoidGlobalVariableInFunctionNonCompliant2.py | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) rename src/test/resources/checks/{avoidGlobalVariableInFunction.py => avoidGlobalVariableInFunctionNonCompliant.py} (100%) create mode 100644 src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant2.py diff --git a/src/test/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheckTest.java b/src/test/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheckTest.java index 5f716d3..e857cc2 100644 --- a/src/test/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheckTest.java +++ b/src/test/java/fr/greencodeinitiative/python/checks/AvoidGlobalVariableInFunctionCheckTest.java @@ -23,6 +23,8 @@ public class AvoidGlobalVariableInFunctionCheckTest { @Test public void test() { - PythonCheckVerifier.verify("src/test/resources/checks/avoidGlobalVariableInFunction.py", new AvoidGlobalVariableInFunctionCheck()); + PythonCheckVerifier.verify("src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant.py", new AvoidGlobalVariableInFunctionCheck()); + //PythonCheckVerifier.verifyNoIssue("src/test/resources/checks/avoidGlobalVariableInFunctionCompliant.py", new AvoidGlobalVariableInFunctionCheck()); + PythonCheckVerifier.verify("src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant2.py", new AvoidGlobalVariableInFunctionCheck()); } } diff --git a/src/test/resources/checks/avoidGlobalVariableInFunction.py b/src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant.py similarity index 100% rename from src/test/resources/checks/avoidGlobalVariableInFunction.py rename to src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant.py diff --git a/src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant2.py b/src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant2.py new file mode 100644 index 0000000..f1bfa74 --- /dev/null +++ b/src/test/resources/checks/avoidGlobalVariableInFunctionNonCompliant2.py @@ -0,0 +1,10 @@ +# example from official Python documentation + +from collections.abc import Sequence +from typing import TypeVar + +U = TypeVar('U') # Declare type variable "U" + +def second(l: Sequence[U]) -> U: # Function is generic over the TypeVar "U" + print(U) #Noncompliant + return l[1] \ No newline at end of file