Skip to content

Commit

Permalink
Whitelists: use non-dynamic objects directly instead of mocking them. (
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ722 authored and jendrikseipp committed Jul 1, 2018
1 parent be667ec commit 3899b22
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 41 deletions.
1 change: 1 addition & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ News
* Don't import any Vulture modules in setup.py (thanks @RJ722).
* Add ``*-test.py`` to recognized test file patterns.
* Add ``failureException``, ``longMessage`` and ``maxDiff`` to ``unittest`` whitelist.
* Refer to actual objects rather than their mocks in default whitelists.


0.27 (2018-06-05)
Expand Down
1 change: 0 additions & 1 deletion TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ TODOs
* Use coverage.py to detect false-positives (#109).
* Write script for turning SIP files into whitelists (#8).
* Add PyQT whitelist to Vulture repo?
* Use real objects instead of mocks in whitelists where possible (#136).


Non-TODOs
Expand Down
2 changes: 1 addition & 1 deletion vulture/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def exclude_file(name):

unique_imports = set(item.name for item in self.defined_imports)
for import_name in unique_imports:
path = os.path.join('whitelists', import_name) + '.py'
path = os.path.join('whitelists', import_name) + '_whitelist.py'
if exclude_file(path):
self._log('Excluded whitelist:', path)
else:
Expand Down
8 changes: 0 additions & 8 deletions vulture/whitelists/argparse.py

This file was deleted.

7 changes: 7 additions & 0 deletions vulture/whitelists/argparse_whitelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import argparse

_ = argparse.ArgumentParser()
_.epilog

argparse.ArgumentDefaultsHelpFormatter._fill_text
argparse.ArgumentDefaultsHelpFormatter._get_help_string
File renamed without changes.
5 changes: 0 additions & 5 deletions vulture/whitelists/collections.py

This file was deleted.

4 changes: 4 additions & 0 deletions vulture/whitelists/collections_whitelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import collections

# To free memory, the "default_factory" attribute can be set to None.
collections.defaultdict.default_factory
7 changes: 0 additions & 7 deletions vulture/whitelists/sys.py

This file was deleted.

6 changes: 6 additions & 0 deletions vulture/whitelists/sys_whitelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys

# Never report redirected streams as unused.
sys.stderr
sys.stdin
sys.stdout
19 changes: 0 additions & 19 deletions vulture/whitelists/unittest.py

This file was deleted.

26 changes: 26 additions & 0 deletions vulture/whitelists/unittest_whitelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from unittest import TestCase

TestCase.setUp
TestCase.tearDown
TestCase.setUpClass
TestCase.tearDownClass
TestCase.run
TestCase.skipTest
TestCase.debug
TestCase.failureException
TestCase.longMessage
TestCase.maxDiff
try:
# new in Python 3.4
TestCase.subTest
except AttributeError:
pass

try:
# unittest.mock was introduced in Python 3.3
from unittest import mock
except ImportError:
pass
else:
mock.Mock.return_value
mock.Mock.side_effect

0 comments on commit 3899b22

Please sign in to comment.