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

Improved test coverage in 5 places for production code #696

Merged
merged 10 commits into from
Jul 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixed two problems
mtrd3v committed Jul 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 953201e771224cae4e781584622221774db92530
2 changes: 1 addition & 1 deletion src/icalendar/prop.py
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ def to_ical(self):
def from_ical(ical):
try:
return base64.b64decode(ical)
except UnicodeError:
except (ValueError, UnicodeError):
raise ValueError('Not valid base 64 encoding.')

def __eq__(self, other):
12 changes: 12 additions & 0 deletions src/icalendar/tests/prop/test_vBinary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Test vBinary"""
import pytest

from icalendar import vBinary
from icalendar.parser import Parameters

@@ -27,3 +29,13 @@ def test_long_data():
txt_ical = b'YWFh' * 33
assert (vBinary(txt).to_ical() == txt_ical)
assert (vBinary.from_ical(txt_ical) == txt)

def test_repr():
instance = vBinary("value")
assert repr(instance) == "vBinary('b'dmFsdWU='')"

def test_from_ical():
with pytest.raises(ValueError, match='Not valid base 64 encoding.'):
vBinary.from_ical("value")
with pytest.raises(ValueError, match='Not valid base 64 encoding.'):
vBinary.from_ical("áèਮ")