GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — gh-108885: Use subtests for doctest examples run by unittest by serhiy-storchaka · Pull Request #134890 · python/cpython Conversation
|
| except: | ||
| exception = sys.exc_info() | ||
| exc_info = sys.exc_info() | ||
| exc_info = (*exc_info[:2], exc_info[2].tb_next) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We don't need to use sys here:
except BaseException as e:
exc_info = type(e), e, e.__traceback__.tb_next
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, save just the exception here and access its parts below where you need them.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It does not work, because a traceback here is a not a real traceback. You cannot set it as the part of the exception. Fortunately, all traceback formatting functions and TestCase.addSubTest() work with the exc_info triple.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Well, here it is a real traceback, but in other place we use a mock traceback, so it is easier to use the same pattern here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant that you extract it from the exception object when you need it below (in this function) and pass that to the internal functions that want the triplet. Just get it from the exception and not from sys.exc_info(). It's the same thing.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This line is actually a part of #134858.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I applied your suggestion there.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Run each example as a subtest in unit tests synthesized by doctest.DocFileSuite() and doctest.DocTestSuite().
46860db to
55da0a1
Compare
There was an error while loading. Please reload this page.
|
Before merging this PR I am going to create and merge a PR for documentation fixes, because the current documentation has some errors. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ythonGH-134890) Run each example as a subtest in unit tests synthesized by doctest.DocFileSuite() and doctest.DocTestSuite(). Add the doctest.DocTestRunner.report_skip() method.
…ythonGH-134890) Run each example as a subtest in unit tests synthesized by doctest.DocFileSuite() and doctest.DocTestSuite(). Add the doctest.DocTestRunner.report_skip() method.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.