Skip to content

Commit

Permalink
Fixed pylint warning from code similarities in tests
Browse files Browse the repository at this point in the history
The test code contain setup and teardown that are same for
two tests. Pylint complains about these two methods in two
modules. The setup and teardown are needed because they are
called by the test framework and cannot be removed.

It seems that pylint 1.7.2 has open fault that makes disabling
of the check in portion of the code not to work /1/.

It also seems that pylint 1.7.2 the ignore-comments and
ignore-docstrings do not seem to work as expected. Even
when the values should state that these are ignored, the
min-similarity had to be increased to 8 because there are
7 lines in these two referred methods.

The target is to get the warnings down to see changes
easily. This fix could be fixed later on by setting the
min-similarity to 4 and use the ignore docstring and
comment settings combined with the code tag to ignore
the duplicated code.

/1/ pylint-dev/pylint#214

Signed-off-by: Heikki Laaksonen <[email protected]>
  • Loading branch information
heilaaks committed Jul 30, 2017
1 parent 69b2847 commit 3a3f27c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tests/pylint/pylint-snippy-tests.rc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ ignore-docstrings=yes
ignore-imports=no

# Minimum lines number of a similarity.
min-similarity-lines=4
min-similarity-lines=8


[SPELLING]
Expand Down
21 changes: 2 additions & 19 deletions tests/pylint/pylint-snippy-tests.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
************* Module tests.testlib.argument_helper
R: 1, 0: Similar lines in 2 files
==tests.test_arguments_add_new_snippet:181
==tests.test_config_add_new_snippet:223
@classmethod
def setup_class(cls):
"""Test class setup before any of the tests are run."""

print('setup_class()')
ArgumentHelper().reset()

@classmethod
def teardown_class(cls):
"""Test class teardown after all tests run."""

print('teardown_class()')
ArgumentHelper().reset() (duplicate-code)

------------------------------------------------------------------
Your code has been rated at 9.97/10 (previous run: 9.97/10, +0.00)
-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 9.97/10, +0.03)

1 change: 1 addition & 0 deletions tests/test_arguments_add_new_snippet.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def test_valid_value_with_tags_with_special_characters(self):
assert obj.get_tags() == tags
assert obj.get_comment() == ''

# pylint: disable=duplicate-code
@classmethod
def setup_class(cls):
"""Test class setup before any of the tests are run."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_config_add_new_snippet.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def test_valid_value_with_tags_with_special_characters(self):
assert set(obj.get_tags()) == set(tags)
assert len(obj.get_tags()) == 3

# pylint: disable=duplicate-code
@classmethod
def setup_class(cls):
"""Test class setup before any of the tests are run."""
Expand Down

0 comments on commit 3a3f27c

Please sign in to comment.