dirty-equals
dirty-equals copied to clipboard
feat: add IsUrl
Here's a first go at this. I didn't write too many test cases since most of the Url checking logic is already tested in Pydantic.
Codecov Report
Merging #47 (8f270ef) into main (42c5594) will decrease coverage by
0.27%
. The diff coverage is95.12%
.
Additional details and impacted files
@@ Coverage Diff @@
## main #47 +/- ##
===========================================
- Coverage 100.00% 99.72% -0.28%
===========================================
Files 12 11 -1
Lines 709 737 +28
Branches 180 188 +8
===========================================
+ Hits 709 735 +26
- Misses 0 2 +2
Impacted Files | Coverage Δ | |
---|---|---|
dirty_equals/_other.py | 98.46% <95.12%> (-1.54%) |
:arrow_down: |
dirty_equals/__init__.py |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 42c5594...8f270ef. Read the comment docs.
Ready for review!
Sorry I couldn't figure out how to test the optional import of Pydantic throwing an error.
This was the closest I got but it doesn't work since the mocked_pydantic
object is just imported in ._other.py
rather than called.
def test_import_error_throws():
import sys
from unittest.mock import Mock
mocked_pydantic = Mock(side_effect=ImportError)
sys.modules['pydantic'] = mocked_pydantic
with pytest.raises(
ImportError,
match='pydantic is not installed, run `pip install dirty-equals[pydantic]`',
):
from dirty_equals import IsUrl
assert 'https://example.com' == IsUrl