pytest-tap icon indicating copy to clipboard operation
pytest-tap copied to clipboard

Add ability to write YAML blocks based on test decorator

Open richard-bosworth opened this issue 7 years ago • 4 comments

As of tap version 13 YAML blocks are supported. Tappy allows for reading these YAML blocks but it would be great if the pytest tap plugin could write the YAML blocks based on some information coming from the tests themselves.

I implemented this locally using a decorator for the tests and by adding an extra hook method to the pytest tap plugin.py.

The decorator takes a string which represents the body of the YAML block, which should be added to the tap report, and adds it to the TestCase in question.

The hook method then takes this additional information and adds it to the TAP line to be written.

In this way the YAML block is defined by the test writer - it might also be nice to be able to fill the YAML block with some of the other automated outputs of tests.

I've got some code I can share but new to this area so not sure if it's the right way to do it. Links very closely to an issue I just submitted here

richard-bosworth avatar May 25 '18 15:05 richard-bosworth

I can consider a PR if you can push code up to GitHub.

Abstractly, yes, it would be nice if pytest-tap could output YAML blocks in a configurable way. I'm not sure how best to expose data or how to add more information. Having some code to look through could help work through an appropriate API.

mblayman avatar May 25 '18 15:05 mblayman

Ok will do - should I do that as a PR from a fork?

richard-bosworth avatar May 25 '18 16:05 richard-bosworth

Yeah, sorry. I take it for granted that I do GitHub on a daily basis for work and not everyone knows how to do this stuff.

Here's roughly the process:

  1. Make a fork.
  2. Make a local clone.
  3. Make a branch in that clone.
  4. Write the code you want to write.
  5. Commit to that branch.
  6. Push the local branch up to the fork on GitHub.
  7. From the GitHub UI on the tappy page, propose a PR.

If you need more guidance, I can help along the way.

mblayman avatar May 25 '18 16:05 mblayman

That's awesome - will get the PR up (We use Atlassian for work so not used to GitHub but pretty much the same process)

richard-bosworth avatar May 25 '18 17:05 richard-bosworth