Skip to content

Commit 4198d5a

Browse files
authored
Adds pylintrc and moves towards conforming to the pylintrc (google#36)
* Adds pylintrc and moves towards conforming to that pylintrc. * Also moves all tests to use testutils.BaseTestCase. Copybara generated commit for Python Fire. PiperOrigin-RevId: 151341797 Change-Id: I1c4d7ecf1fc4d7931e6c91328649fa5da9e916e1 Reviewed-on: https://team-review.git.corp.google.com/65525 Reviewed-by: David Bieber <dbieber@google.com>
1 parent 05d5933 commit 4198d5a

22 files changed

+322
-69
lines changed

examples/cipher/cipher_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from fire.examples.cipher import cipher
15+
from fire import testutils
1616

17-
import unittest
17+
from fire.examples.cipher import cipher
1818

1919

20-
class CipherTest(unittest.TestCase):
20+
class CipherTest(testutils.BaseTestCase):
2121

2222
def testCipher(self):
2323
self.assertEqual(cipher.rot13('Hello world!'), 'Uryyb jbeyq!')
@@ -29,4 +29,4 @@ def testCipher(self):
2929

3030

3131
if __name__ == '__main__':
32-
unittest.main()
32+
testutils.main()

examples/diff/diff_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
import tempfile
1616

17+
from fire import testutils
18+
1719
from fire.examples.diff import diff
1820
from fire.examples.diff import difffull
1921

20-
import unittest
21-
2222

23-
class DiffTest(unittest.TestCase):
23+
class DiffTest(testutils.BaseTestCase):
2424
"""The purpose of these tests is to ensure the difflib wrappers works.
2525
2626
It is not the goal of these tests to exhaustively test difflib functionality.
@@ -90,4 +90,4 @@ def testDiffFull(self):
9090

9191

9292
if __name__ == '__main__':
93-
unittest.main()
93+
testutils.main()

examples/widget/collector_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from fire import testutils
16+
1517
from fire.examples.widget import collector
1618
from fire.examples.widget import widget
1719

18-
import unittest
19-
2020

21-
class CollectorTest(unittest.TestCase):
21+
class CollectorTest(testutils.BaseTestCase):
2222

2323
def testCollectorHasWidget(self):
2424
col = collector.Collector()
@@ -34,4 +34,4 @@ def testCollectorGetsWantedWidgets(self):
3434

3535

3636
if __name__ == '__main__':
37-
unittest.main()
37+
testutils.main()

examples/widget/widget_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from fire.examples.widget import widget
15+
from fire import testutils
1616

17-
import unittest
17+
from fire.examples.widget import widget
1818

1919

20-
class WidgetTest(unittest.TestCase):
20+
class WidgetTest(testutils.BaseTestCase):
2121

2222
def testWidgetWhack(self):
2323
toy = widget.Widget()
@@ -31,4 +31,4 @@ def testWidgetBang(self):
3131

3232

3333
if __name__ == '__main__':
34-
unittest.main()
34+
testutils.main()

fire/completion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,3 @@ def _Commands(component, depth=3):
226226

227227
for command in _Commands(member, depth - 1):
228228
yield (member_name,) + command
229-

fire/completion_test.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
"""Tests for the completion module."""
16+
1517
from __future__ import absolute_import
1618
from __future__ import division
1719
from __future__ import print_function
1820

1921
from fire import completion
2022
from fire import test_components as tc
21-
22-
import unittest
23+
from fire import testutils
2324

2425

25-
class TabCompletionTest(unittest.TestCase):
26+
class TabCompletionTest(testutils.BaseTestCase):
2627

2728
def testCompletionScript(self):
2829
# A sanity check test to make sure the completion script satisfies some
@@ -32,7 +33,7 @@ def testCompletionScript(self):
3233
['halt'],
3334
['halt', '--now'],
3435
]
35-
script = completion._Script(name='command', commands=commands)
36+
script = completion._Script(name='command', commands=commands) # pylint: disable=protected-access
3637
self.assertIn('command', script)
3738
self.assertIn('halt', script)
3839
self.assertIn('"$start" == "command"', script)
@@ -135,4 +136,4 @@ def testMethodCompletions(self):
135136

136137

137138
if __name__ == '__main__':
138-
unittest.main()
139+
testutils.main()

fire/core_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
"""Tests for the core module."""
16+
1517
from __future__ import absolute_import
1618
from __future__ import division
1719
from __future__ import print_function
@@ -22,16 +24,14 @@
2224
from fire import trace
2325
import mock
2426

25-
import unittest
26-
2727

2828
class CoreTest(testutils.BaseTestCase):
2929

3030
def testOneLineResult(self):
31-
self.assertEqual(core._OneLineResult(1), '1')
32-
self.assertEqual(core._OneLineResult('hello'), 'hello')
33-
self.assertEqual(core._OneLineResult({}), '{}')
34-
self.assertEqual(core._OneLineResult({'x': 'y'}), '{"x": "y"}')
31+
self.assertEqual(core._OneLineResult(1), '1') # pylint: disable=protected-access
32+
self.assertEqual(core._OneLineResult('hello'), 'hello') # pylint: disable=protected-access
33+
self.assertEqual(core._OneLineResult({}), '{}') # pylint: disable=protected-access
34+
self.assertEqual(core._OneLineResult({'x': 'y'}), '{"x": "y"}') # pylint: disable=protected-access
3535

3636
@mock.patch('fire.interact.Embed')
3737
def testInteractiveMode(self, mock_embed):
@@ -94,4 +94,4 @@ def testFireErrorMultipleValues(self):
9494
self.assertIsNotNone(error)
9595

9696
if __name__ == '__main__':
97-
unittest.main()
97+
testutils.main()

fire/decorators_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
"""Tests for the decorators module."""
16+
1517
from __future__ import absolute_import
1618
from __future__ import division
1719
from __future__ import print_function
1820

1921
from fire import core
2022
from fire import decorators
21-
22-
import unittest
23+
from fire import testutils
2324

2425

2526
class A(object):
@@ -88,7 +89,7 @@ def example7(self, arg1, arg2=None, *varargs, **kwargs):
8889
return arg1, arg2, varargs, kwargs
8990

9091

91-
class FireDecoratorsTest(unittest.TestCase):
92+
class FireDecoratorsTest(testutils.BaseTestCase):
9293

9394
def testSetParseFnsNamedArgs(self):
9495
self.assertEqual(core.Fire(A, 'double 2'), 4)
@@ -147,4 +148,4 @@ def testSetParseFn(self):
147148

148149

149150
if __name__ == '__main__':
150-
unittest.main()
151+
testutils.main()

fire/fire_import_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import mock
15+
"""Tests importing the fire module."""
16+
1617
import sys
17-
import unittest
1818

1919
import fire
20+
from fire import testutils
21+
import mock
2022

2123

22-
class FireImportTest(unittest.TestCase):
24+
class FireImportTest(testutils.BaseTestCase):
2325
"""Tests importing Fire."""
2426

2527
def testFire(self):
@@ -35,4 +37,4 @@ def testNoPrivateMethods(self):
3537

3638

3739
if __name__ == '__main__':
38-
unittest.main()
40+
testutils.main()

fire/fire_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
"""Tests for the fire module."""
16+
1517
from __future__ import absolute_import
1618
from __future__ import division
1719
from __future__ import print_function
@@ -414,4 +416,4 @@ def testTraceErrors(self):
414416

415417

416418
if __name__ == '__main__':
417-
unittest.main()
419+
testutils.main()

0 commit comments

Comments
 (0)