Skip to content

Commit

Permalink
pytest: Tests: Derive from pytest.Function rather than Item
Browse files Browse the repository at this point in the history
This way VSCode will still include us in the list of results.

See also: [vscode-python#8242] where it broke, [vscode-python#8245] which
is the issue tracking fixing it and [_get_item_kind] which is the function
which figures out whether this is an pytest test function or not.

[vscode-python#8242]: microsoft/vscode-python#8242
[vscode-python#8245]: microsoft/vscode-python#8425
[_get_item_kind]: https://github.com/microsoft/vscode-python/blob/411d1d4ae7e3884a8ef9294a0aa1688dc05d0f37/pythonFiles/testing_tools/adapter/pytest/_pytest_item.py#L530-L540
  • Loading branch information
wmanley committed Apr 2, 2021
1 parent 6a5a2d6 commit 89f7a27
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions stbt_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,8 +1328,12 @@ def collect(self):
self, self.name, m.group(1), n + 1)
yield srt

@property
def obj(self):
return globals()

class StbtRemoteTest(pytest.Item):

class StbtRemoteTest(pytest.Function):
# pylint: disable=abstract-method
def __init__(self, parent, filename, testname, line_number):
super(StbtRemoteTest, self).__init__(testname, parent)
Expand Down Expand Up @@ -1360,7 +1364,12 @@ def runtest(self):
self.session.stbt_args.test_cases = None

def reportinfo(self):
return self.fspath, self._line_number, ""
return self.fspath, self._line_number, self._testname

def _getobj(self):
def myfunc():
pass
return myfunc

class Args(object):
"""Pretends to be the result of calling `argparser` `parse_args` so we
Expand Down

0 comments on commit 89f7a27

Please sign in to comment.