Skip to content

Commit 8469e48

Browse files
authored
Move python 3 only component to test_components_py3.py (#389)
* #316 adds a test using Python 3 only features; this CL makes that test only run for Python 3 versions.
1 parent 09f836e commit 8469e48

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

.github/scripts/build.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,10 @@ python -m pytest # Run the tests without IPython.
2929
pip install ipython
3030
python -m pytest # Now run the tests with IPython.
3131
pylint fire --ignore=test_components_py3.py,parser_fuzz_test.py,console
32-
if [[ ${PYTHON_VERSION} == 2.7 || ${PYTHON_VERSION} == 3.7 ]]; then
32+
if [[ ${PYTHON_VERSION} == 3.7 ]]; then
3333
pip install pytype;
3434
fi
35-
# Run type-checking, excluding files that define or use py3 features in py2.
36-
if [[ ${PYTHON_VERSION} == 2.7 ]]; then
37-
pytype -x \
38-
fire/fire_test.py \
39-
fire/inspectutils_test.py \
40-
fire/test_components_py3.py;
41-
elif [[ ${PYTHON_VERSION} == 3.7 ]]; then
35+
# Run type-checking.
36+
if [[ ${PYTHON_VERSION} == 3.7 ]]; then
4237
pytype -x fire/test_components_py3.py;
4338
fi
44-

fire/helptext_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,11 @@ def testUsageOutputFunctionWithDocstring(self):
497497
textwrap.dedent(expected_output).lstrip('\n'),
498498
usage_output)
499499

500+
@testutils.skipIf(
501+
six.PY2,
502+
'Python 2 does not support required name-only arguments.')
500503
def testUsageOutputFunctionMixedDefaults(self):
501-
component = tc.MixedDefaults().identity2
504+
component = tc.py3.HelpTextComponent().identity
502505
t = trace.FireTrace(component, name='FunctionMixedDefaults')
503506
usage_output = helptext.UsageText(component, trace=t, verbose=False)
504507
expected_output = """

fire/test_components.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ def sum(self, alpha=0, beta=0):
133133
def identity(self, alpha, beta='0'):
134134
return alpha, beta
135135

136-
def identity2(self, *, alpha, beta='0'):
137-
return alpha, beta
138-
139136

140137
class SimilarArgNames(object):
141138

fire/test_components_py3.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ def identity(arg1, arg2: int, arg3=10, arg4: int = 20, *arg5,
2525
return arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10
2626

2727

28+
class HelpTextComponent:
29+
30+
def identity(self, *, alpha, beta='0'):
31+
return alpha, beta
32+
33+
2834
class KeywordOnly(object):
2935

3036
def double(self, *, count):

0 commit comments

Comments
 (0)