Skip to content
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

Pytest with demo.py #226

Closed
wants to merge 11 commits into from
Closed

Pytest with demo.py #226

wants to merge 11 commits into from

Conversation

eggplants
Copy link
Contributor

Closes: #224

@eggplants
Copy link
Contributor Author

eggplants commented Mar 6, 2022

---------- coverage: platform linux, python 3.6.15-final-0 -----------
Name                   Stmts   Miss  Cover
------------------------------------------
demo.py                  177     12    93%
pixivpy3/__init__.py       5      0   100%
pixivpy3/aapi.py         298     63    79%
pixivpy3/api.py          105     36    66%
pixivpy3/bapi.py          23     14    39%
pixivpy3/utils.py         21      6    71%
------------------------------------------
TOTAL                    629    131    79%


============================== 9 passed in 27.26s ==============================

@eggplants
Copy link
Contributor Author

eggplants commented Mar 6, 2022

If you like, consider introducing Codecov.

@Xdynix Xdynix requested a review from upbit March 6, 2022 05:45
@Xdynix
Copy link
Collaborator

Xdynix commented Mar 6, 2022

Will we add a minimum coverage requirement? If so then we may need to consider to rewrite the tests.

@upbit
Copy link
Owner

upbit commented Mar 6, 2022

Thanks for helping keep improving PixivPy 👍

However, pytest --cov is still a bit different from python demo.py. Currently coverage only checks the coverage of code lines, and does not assert the expected return results. A relatively simple modification may be to add an additional step for the code coverage check.

@upbit
Copy link
Owner

upbit commented Mar 6, 2022

The API is relatively simple at present, and there is not a lot of processing logic, so I have not considered doing interface testing before.

If you want to write tests, you can consider testing the framework through a JSON-driven interface. For example, read the JSON result of the file through responses, and then assert the results. The advantage of this method is stability, the disadvantage is that it is more troublesome to maintain the JSON files.
Another idea is to directly use the interface of Pixiv for interface testing, which should completely replace thedemo.py, which not only completes the call to the interface and page turning, but also checks whether the response meets expectations (for example, whether type=illust returned novel, etc.)

@eggplants
Copy link
Contributor Author

assert the expected return results

Another idea is to directly use the interface of Pixiv for interface testing, which should completely replace the demo.py, which not only completes the call to the interface and page turning, but also checks whether the response meets expectations (for example, whether type=illust returned novel, etc.)

I will try to do them later.

@eggplants eggplants marked this pull request as draft March 6, 2022 06:32
@eggplants eggplants closed this Mar 7, 2022
@eggplants eggplants deleted the test branch March 26, 2022 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edit demo.py for pytest
3 participants