-
-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for python code in documentation #3394
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to review pull request #3394 due to the following error:
<class 'KeyError'>: 0
Try re-running the review or contact [email protected] for help.
Thanks for adding the Here's a preview of the changelog: Adds documentation tests for python code blocks in any markdown files in the Here's the tweet text:
|
Thanks for adding the Here's a preview of the changelog: Adds documentation tests for python code blocks in any markdown files in the Here's the tweet text:
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3394 +/- ##
==========================================
- Coverage 96.47% 94.38% -2.10%
==========================================
Files 509 506 -3
Lines 32691 31608 -1083
Branches 5399 3644 -1755
==========================================
- Hits 31539 29833 -1706
- Misses 941 1509 +568
- Partials 211 266 +55 |
CodSpeed Performance ReportMerging #3394 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome proposal @Sirusblk! Your changes look good to me, I cross-checked them with the pytest-examples docs.
The CI failures seem to be present on the main branch as well. I'll approve this PR, but will wait for our CI to go green again before merging :)
I'll see if I can find a solution to making sure the schema matches the python code snippet. I'll also look into seeing if we can test the response as well.
pytest-examples docs do show we can handle prints like so: print(1 + 2)
#> 3 If you like this I can go ahead and try this out where appropriate. If the syntax doesn't look good we could try assert statements or roll our own syntax like you suggested. We do reuse a lot of the same structures we could inject some prebuilt data structures into the module namespace when testing to avoid repeat code in each example snippet. For testing schemas, we might be able to similarly use the extracted code examples and be able to compare afterward. I'll poke around and see.
I marked them as flaky so it wouldn't block pytest runs but I can remove that and limiting the scope to possibly a file or two with the documentation updated to get started I figured trying to rewrite all the examples all at once might be too much for a single MR. I could tackle this with a string of MRs once we have a solid base to work from. Thanks for the feedback! |
I think for now it would be fine to just go with this:
we can make it better in future, I'm afraid I'd do to much bike shedding :D For the imports, I think it's fine to leave them in, I'll test if we can hide them from the docs side 😊 maybe we do a flag like this: import strawberry
@strawerry.type
class P:
a: str |
@patrick91 I figured out a way to test I'm still trying to find a good way to handle |
Never mind I adapted some of the |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
… snippets. Refactor code
Description
Add tests for python code in documentation. Adds a new dev dependency:
pytest-examples
and with that package is a single parameterized pytest intests/docs/test_docs.py
which will automatically search the docs folder for any python code examples inTypes of Changes
Issues Fixed or Closed by This PR
Checklist