Optimize another very slow test

This commit is contained in:
Hugo Osvaldo Barrera 2021-06-12 23:49:23 +02:00
parent 910317d4bb
commit 5e36ca1334

View file

@ -2,9 +2,7 @@ import json
import sys import sys
from textwrap import dedent from textwrap import dedent
import hypothesis.strategies as st
import pytest import pytest
from hypothesis import settings
def test_simple_run(tmpdir, runner): def test_simple_run(tmpdir, runner):
@ -299,42 +297,22 @@ def test_multiple_pairs(tmpdir, runner):
} }
collections_strategy = st.sets(
st.text(
st.characters(
blacklist_characters=set("./\x00"), # Invalid chars on POSIX filesystems
# Surrogates can't be encoded to utf-8 in Python
blacklist_categories={"Cs"},
),
min_size=1,
max_size=50,
),
min_size=1,
)
# XXX: https://github.com/pimutils/vdirsyncer/issues/617 # XXX: https://github.com/pimutils/vdirsyncer/issues/617
@pytest.mark.skipif(sys.platform == "darwin", reason="This test inexplicably fails") @pytest.mark.skipif(sys.platform == "darwin", reason="This test inexplicably fails")
@pytest.mark.parametrize( @pytest.mark.parametrize(
"collections", "collections",
[ [
("persönlich",), ("a", "A"),
(
"a",
"A",
),
("\ufffe",), ("\ufffe",),
] ("Hello there!",),
+ [ ("Österreich",),
collections_strategy.example() ("中国", "x1"),
for _ in range(settings.get_profile(settings._current_profile).max_examples) ("한글",),
("42a4ec99-b1c2-4859-b142-759112f2ca50",),
("فلسطين",),
], ],
) )
def test_create_collections(collections, tmpdir, runner): def test_create_collections(collections, tmpdir, runner):
# Hypothesis calls this tests in a way that fixtures are not reset, to tmpdir is the
# same for each call.
# This horrible hack creates a new subdirectory on each run, effectively giving us a
# new tmpdir each run.
runner.write_with_general( runner.write_with_general(
dedent( dedent(