Skip to content

Commit 44bedd8

Browse files
committed
Fixed Edge Cases for < 3.7 Repeated and Tag Str Parameters
1 parent 2e15c5c commit 44bedd8

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/inline/plugin.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,22 +505,30 @@ class ConstrArgs(enum.Enum):
505505
if arg_type == None:
506506
corr_val_type = True
507507
break
508-
if isinstance(arg.value, arg_type):
508+
if isinstance(getattr(arg, value_prop_name), arg_type):
509509
corr_val_type = True
510510
break
511511

512512
if corr_val_type and corr_arg_type:
513513
# Accounts for additional checks for REPEATED and TAG_STR arguments
514514
if arg_idx == ConstrArgs.REPEATED:
515-
if arg.value <= 0:
515+
value = getattr(arg, value_prop_name)
516+
if value <= 0:
516517
raise MalformedException(f"inline test: {self.arg_repeated_str} must be greater than 0")
517-
self.cur_inline_test.repeated = getattr(arg, value_prop_name)
518+
self.cur_inline_test.repeated = value
518519
elif arg_idx == ConstrArgs.TAG_STR:
519520
tags = []
521+
522+
if sys.version_info < (3, 8, 0):
523+
elt_type = ast.Str
524+
else:
525+
elt_type = ast.Constant
526+
520527
for elt in arg.elts:
521-
if not (isinstance(elt, ast.Constant) and isinstance(elt.value, str)):
528+
value = getattr(elt, value_prop_name)
529+
if (not isinstance(elt, elt_type) and isinstance(value, str)):
522530
raise MalformedException(f"tag can only be List of string")
523-
tags.append(getattr(elt, value_prop_name))
531+
tags.append(value)
524532
self.cur_inline_test.tag = tags
525533
# For non-special cases, set the attribute defined by the dictionary
526534
else:

tests/test_plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
from _pytest.pytester import Pytester
33
import pytest
44

5+
# For testing in Spyder only
6+
if __name__ == "__main__":
7+
pytest.main(['-v', '-s'])
8+
59

610
# pytest -p pytester
711
class TestInlinetests:

0 commit comments

Comments
 (0)