mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Add benchmarks to vobject parsing tests
This commit is contained in:
parent
fb5ed72c93
commit
42662a97c3
1 changed files with 10 additions and 9 deletions
|
|
@ -24,8 +24,8 @@ _simple_joined = u'\r\n'.join(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_split_collection_simple():
|
def test_split_collection_simple(benchmark):
|
||||||
given = list(vobject.split_collection(_simple_joined))
|
given = benchmark(lambda: list(vobject.split_collection(_simple_joined)))
|
||||||
|
|
||||||
assert [normalize_item(item) for item in given] == \
|
assert [normalize_item(item) for item in given] == \
|
||||||
[normalize_item(item) for item in _simple_split]
|
[normalize_item(item) for item in _simple_split]
|
||||||
|
|
@ -35,14 +35,14 @@ def test_split_collection_simple():
|
||||||
[x.splitlines() for x in _simple_split]
|
[x.splitlines() for x in _simple_split]
|
||||||
|
|
||||||
|
|
||||||
def test_split_collection_multiple_wrappers():
|
def test_split_collection_multiple_wrappers(benchmark):
|
||||||
joined = u'\r\n'.join(
|
joined = u'\r\n'.join(
|
||||||
u'BEGIN:VADDRESSBOOK\r\n' +
|
u'BEGIN:VADDRESSBOOK\r\n' +
|
||||||
x +
|
x +
|
||||||
u'\r\nEND:VADDRESSBOOK\r\n'
|
u'\r\nEND:VADDRESSBOOK\r\n'
|
||||||
for x in _simple_split
|
for x in _simple_split
|
||||||
)
|
)
|
||||||
given = list(vobject.split_collection(joined))
|
given = benchmark(lambda: list(vobject.split_collection(joined)))
|
||||||
|
|
||||||
assert [normalize_item(item) for item in given] == \
|
assert [normalize_item(item) for item in given] == \
|
||||||
[normalize_item(item) for item in _simple_split]
|
[normalize_item(item) for item in _simple_split]
|
||||||
|
|
@ -67,15 +67,15 @@ def test_split_collection_different_wrappers():
|
||||||
str(exc_info.value).lower()
|
str(exc_info.value).lower()
|
||||||
|
|
||||||
|
|
||||||
def test_join_collection_simple():
|
def test_join_collection_simple(benchmark):
|
||||||
given = vobject.join_collection(_simple_split)
|
given = benchmark(lambda: vobject.join_collection(_simple_split))
|
||||||
assert normalize_item(given) == normalize_item(_simple_joined)
|
assert normalize_item(given) == normalize_item(_simple_joined)
|
||||||
if vobject.ICALENDAR_ORIGINAL_ORDER_SUPPORT:
|
if vobject.ICALENDAR_ORIGINAL_ORDER_SUPPORT:
|
||||||
assert given.splitlines() == _simple_joined.splitlines()
|
assert given.splitlines() == _simple_joined.splitlines()
|
||||||
|
|
||||||
|
|
||||||
def test_join_collection_vevents():
|
def test_join_collection_vevents(benchmark):
|
||||||
actual = vobject.join_collection([
|
actual = benchmark(lambda: vobject.join_collection([
|
||||||
dedent("""
|
dedent("""
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
BEGIN:VTIMEZONE
|
BEGIN:VTIMEZONE
|
||||||
|
|
@ -86,7 +86,8 @@ def test_join_collection_vevents():
|
||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
""").format(i) for i in range(3)
|
""").format(i) for i in range(3)
|
||||||
])
|
]))
|
||||||
|
|
||||||
expected = dedent("""
|
expected = dedent("""
|
||||||
BEGIN:VCALENDAR
|
BEGIN:VCALENDAR
|
||||||
BEGIN:VTIMEZONE
|
BEGIN:VTIMEZONE
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue