8000 Add InvalidProperty test and fix the travis error resulting from pyty… · randomprin/python-fire@04e2434 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04e2434

Browse files
dbiebercopybara-github
authored andcommitted
Add InvalidProperty test and fix the travis error resulting from pytype not being supported in python 3.4
PiperOrigin-RevId: 297245710 Change-Id: I0b0f6110f2aeb1951a585be3532e8d49c22e41c7
1 parent 297a1ad commit 04e2434

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ script:
2323
- pip install ipython
2424
- python -m pytest # Now run the tests with IPython.
2525
- pylint fire --ignore=test_components_py3.py,parser_fuzz_test.py,console
26-
- pip install pytype
26+
- if [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then
27+
pip install pytype;
28+
fi
2729
# Run type-checking, excluding files that define or use py3 features in py2.
2830
- if [[ $TRAVIS_PYTHON_VERSION == 2.7 ]]; then
2931
pytype -x
3032
fire/fire_test.py
3133
fire/inspectutils_test.py
3234
fire/test_components_py3.py;
33-
else
34-
pytype; fi
35+
elif [[ $TRAVIS_PYTHON_VERSION != 3.4 ]]; then
36+
pytype;
37+
fi

fire/fire_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,10 @@ def testClassWithDefaultMethod(self):
708708
fire.Fire(tc.DefaultMethod, command=['double', '10']), 20
709709
)
710710

711+
def testClassWithInvalidProperty(self):
712+
self.assertEqual(
713+
fire.Fire(tc.InvalidProperty, command=['double', '10']), 20
714+
)
711715

712716
if __name__ == '__main__':
713717
testutils.main()

fire/test_components.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,3 +509,13 @@ def __getattr__(self, name):
509509
def _missing():
510510
return 'Undefined function'
511511
return _missing
512+
513+
514+
class InvalidProperty(object):
515+
516+
def double(self, number):
517+
return 2 * number
518+
519+
@property
520+
def prop(self):
521+
raise ValueError('test')

0 commit comments

Comments
 (0)
0