Skip to content

Commit dd72cec

Browse files
committed
Fixed Edge Case for Diff Given < 3.7
1 parent 2304fae commit dd72cec

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/inline/plugin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,15 +628,22 @@ def parse_diff_given(self, node):
628628
PROPERTY = 0
629629
VALUES = 1
630630

631+
if sys.version_info >= (3, 8, 0):
632+
attr_name = "value"
633+
else:
634+
attr_name = "s"
635+
636+
631637
if len(node.args) == 2:
632638
if self.cur_inline_test.parameterized:
633639
raise MalformedException("inline test: Parameterized inline tests currently do not support differential tests.")
634640
else:
635641
devices = []
636642
for elt in node.args[VALUES].elts:
637-
if elt.value not in {"cpu", "cuda", "mps"}:
643+
value = getattr(elt, attr_name)
644+
if value not in {"cpu", "cuda", "mps"}:
638645
raise MalformedException(f"Invalid device: {elt.value}. Must be one of ['cpu', 'cuda', 'mps']")
639-
devices.append(elt.value)
646+
devices.append(value)
640647
setattr(self.cur_inline_test, node.args[PROPERTY].id, devices)
641648
else:
642649
raise MalformedException("inline test: invalid diff_given(), expected 2 args")

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
# pytest -p pytester
610
class TestInlinetests:
711
def test_inline_diff_given(self, pytester: Pytester):

0 commit comments

Comments
 (0)