yarl icon indicating copy to clipboard operation
yarl copied to clipboard

🧪 Integrate Hypothesis in tests

Open webknjaz opened this issue 1 year ago • 7 comments

What do these changes do?

$sbj

Are there changes in behavior for the user?

Nah

Related issue number

Nope

Checklist

  • [x] I think the code is well written
  • [x] Unit tests for the changes exist
  • [ ] Documentation reflects the changes
  • [ ] Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> (e.g. 588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the PR
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: Fix issue with non-ascii contents in doctest text files.

webknjaz avatar Apr 26 '23 00:04 webknjaz

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (1456dd6) 99.33% compared to head (98412df) 99.48%. Report is 1 commits behind head on master.

:exclamation: Current head 98412df differs from pull request most recent head 3247e27. Consider uploading reports for the commit 3247e27 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #860      +/-   ##
==========================================
+ Coverage   99.33%   99.48%   +0.14%     
==========================================
  Files          17        4      -13     
  Lines        3315      772    -2543     
  Branches      323        0     -323     
==========================================
- Hits         3293      768    -2525     
+ Misses         22        4      -18     
Flag Coverage Δ
unit 99.48% <ø> (+0.23%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 26 '23 00:04 codecov[bot]

@mjpieters I started looking into using Hypothesis during PyCon (the maintainer helped me start). Does this look like a yarl bug to you? https://github.com/aio-libs/yarl/actions/runs/4813151119/jobs/8569304512?pr=860#step:7:1489

webknjaz avatar Jun 06 '23 15:06 webknjaz

@mjpieters I started looking into using Hypothesis during PyCon (the maintainer helped me start). Does this look like a yarl bug to you? https://github.com/aio-libs/yarl/actions/runs/4813151119/jobs/8569304512?pr=860#step:7:1489

I was going to look into that since I found this PR! It does look like %30 is not being decoded properly, so that does look an awful lot like a bug.

mjpieters avatar Jun 07 '23 13:06 mjpieters

Actually, no this is not a bug in Yarl; it is a bug in your Hypothesis tests. unsafe contains '0':

test_quote_unquote_parameter(
    quoter=yarl._quoting_c._Quoter,
    unquoter=yarl._quoting_c._Unquoter,
    text_input='0',
    safe='',
    unsafe='0',   # <--- 0 is unsafe
    protected='',
    qs=False,
    requote=False,
)

With 0 unsafe, the unquoter must return %30.

Either not tell Hypothesis to provide input to unsafe, or account for characters in unsafe when comparing input and output.

mjpieters avatar Jun 07 '23 13:06 mjpieters

@mjpieters yeah, I never used these and wasn't sure about the semantics which is why I asked you. My objective is to make the foundation for adding more Hypothesis testing in the future and so the contributors could look at the examples...

webknjaz avatar Jun 07 '23 18:06 webknjaz

@mjpieters how about https://github.com/aio-libs/yarl/actions/runs/5206601078/jobs/9393336950?pr=860#step:7:1507 then?

webknjaz avatar Jun 08 '23 02:06 webknjaz

@mjpieters do you have ideas on how to best get this integrated finally? What extra constraints do we need in these tests?

webknjaz avatar Nov 20 '23 22:11 webknjaz