Testing pytest plugin I'm building, how to introspect that Item has an attribute added (using pytester/testdir)? #8239
Unanswered
joshua-badger
asked this question in
Q&A
Replies: 1 comment 4 replies
-
I haven't read the question fully, but just a clarifying question - are you using |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
TL;DR Is there a way, using
testdir
/pytester
to introspect anItem
after it has been run (for testing a plugin, not implementing a plugin)?I'm trying to write a plugin for our organization where we standardize saving test artifacts and displaying them in a pytest-html report.
In the test file, I use testdir.inline_genitems() on the files I build in testdir (see below; have omitted pieces of code irrelevant to the question). From that, I'm able to get the items' nodeids and validate that I've copied the artifacts to where I expect them. Awesome.
But from a code coverage point of view, I don't have a good scope for whether my test items are correctly recording. I'd love to be able to introspect them after a run. (Specifically, whether the artifacts were successfully gathered or not, which would be recorded in the Artifact class.) Unfortunately, I cannot figure out how to do so. Not awesome.
For example: I've tried the
runtest()
method on the Items I got frominline_genitems()
(with or without the lines. It throws the following error:Is there something obvious I've missed? Is there a better way to set up my test file (for example, by NOT using the inspect module to copy hooks/fixtures defined by my plugin into a conftest.py file)?
Relevant code below:
Beta Was this translation helpful? Give feedback.
All reactions