-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONARPY-2283 Add unit tests on S905 and S5914 when an imported class …
…has a property, and its getter is called (#2142)
- Loading branch information
1 parent
d8b1171
commit 0278d5c
Showing
9 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
...n-checks/src/test/resources/checks/unconditionalAssertion/unconditionalAssertionImport.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import unittest | ||
from uselessStatementImported import ClassWithProperty | ||
|
||
class TestClass(unittest.TestCase): | ||
def test(self): | ||
self.assertTrue(42) # Noncompliant | ||
self.assertTrue(ClassWithProperty().my_property) # OK property access that is not a constant and might have side effects |
4 changes: 4 additions & 0 deletions
4
...checks/src/test/resources/checks/unconditionalAssertion/unconditionalAssertionImported.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class ClassWithProperty: | ||
|
||
@property | ||
def my_property(self): ... |
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
python-checks/src/test/resources/checks/uselessStatement/uselessStatementImport.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from uselessStatementImported import ClassWithProperty | ||
|
||
ClassWithProperty().method # Noncompliant | ||
ClassWithProperty().my_property # OK property access that is not a constant and might have side effects |
6 changes: 6 additions & 0 deletions
6
python-checks/src/test/resources/checks/uselessStatement/uselessStatementImported.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class ClassWithProperty: | ||
|
||
def method(self): ... | ||
|
||
@property | ||
def my_property(self): ... |