GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix test discovery crash in pytest adapter on doctest (lineno is None… · mitchell-as/vscode-python@572205d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • news/2 Fixes
    • 7487.md
  • pythonFiles/testing_tools/adapter/pytest
    • _pytest_item.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎news/2 Fixes/7487.md‎

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash when using pytest to discover doctests with unknown line number.
2+
(thanks [Olivier Grisel](https://github.com/ogrisel/))
Collapse file

‎pythonFiles/testing_tools/adapter/pytest/_pytest_item.py‎

Copy file name to clipboardExpand all lines: pythonFiles/testing_tools/adapter/pytest/_pytest_item.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,16 @@ def _get_location(item, testroot, relfile, #*,
274274
# function to be in relfile. So here we ignore any
275275
# other file and just say "somewhere in relfile".
276276
lineno = None
277-
if lineno is None:
278-
lineno = -1 # i.e. "unknown"
279277
elif _matches_relfile(srcfile, testroot, relfile):
280278
srcfile = relfile
281279
# Otherwise we just return the info from item.location as-is.
282280

283281
if not srcfile.startswith('.' + _pathsep):
284282
srcfile = '.' + _pathsep + srcfile
283+
284+
if lineno is None:
285+
lineno = -1 # i.e. "unknown"
286+
285287
# from pytest, line numbers are 0-based
286288
location = '{}:{}'.format(srcfile, int(lineno) + 1)
287289
return location, fullname

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.