Skip to content

Commit 53878f0

Browse files
author
Hugo Osvaldo Barrera
committed
Horrible, nasty hack
1 parent 9df587d commit 53878f0

File tree

2 files changed

+42
-35
lines changed

2 files changed

+42
-35
lines changed

test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ hypothesis>=5.0.0
22
pytest
33
pytest-cov
44
pytest-localserver
5-
pytest-subtesthack

tests/system/cli/test_sync.py

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def get_cfg():
271271
}
272272

273273

274+
hack = 0
275+
276+
274277
# XXX: https://github.com/pimutils/vdirsyncer/issues/617
275278
@pytest.mark.skipif(sys.platform == 'darwin',
276279
reason='This test inexplicably fails')
@@ -291,40 +294,45 @@ def get_cfg():
291294
@example(collections=['persönlich'])
292295
@example(collections={'a', 'A'})
293296
@example(collections={'\ufffe'})
294-
def test_create_collections(subtest, collections):
295-
296-
@subtest
297-
def test_inner(tmpdir, runner):
298-
runner.write_with_general(dedent('''
299-
[pair foobar]
300-
a = "foo"
301-
b = "bar"
302-
collections = {colls}
303-
304-
[storage foo]
305-
type = "filesystem"
306-
path = "{base}/foo/"
307-
fileext = ".txt"
308-
309-
[storage bar]
310-
type = "filesystem"
311-
path = "{base}/bar/"
312-
fileext = ".txt"
313-
'''.format(base=str(tmpdir), colls=json.dumps(list(collections)))))
314-
315-
result = runner.invoke(
316-
['discover'],
317-
input='y\n' * 2 * (len(collections) + 1)
318-
)
319-
assert not result.exception, result.output
320-
321-
result = runner.invoke(
322-
['sync'] + ['foobar/' + x for x in collections]
323-
)
324-
assert not result.exception, result.output
325-
326-
assert {x.basename for x in tmpdir.join('foo').listdir()} == \
327-
{x.basename for x in tmpdir.join('bar').listdir()}
297+
def test_create_collections(collections, tmpdir, runner):
298+
# Hypothesis calls this tests in a way that fixtures are not reset, to tmpdir is the
299+
# same for each call.
300+
# This horrible hack creates a new subdirectory on each run, effectively giving us a
301+
# new tmpdir each run.
302+
global hack
303+
hack += 1
304+
tmpdir = tmpdir / f"sub{hack}"
305+
306+
runner.write_with_general(dedent('''
307+
[pair foobar]
308+
a = "foo"
309+
b = "bar"
310+
collections = {colls}
311+
312+
[storage foo]
313+
type = "filesystem"
314+
path = "{base}/foo/"
315+
fileext = ".txt"
316+
317+
[storage bar]
318+
type = "filesystem"
319+
path = "{base}/bar/"
320+
fileext = ".txt"
321+
'''.format(base=str(tmpdir), colls=json.dumps(list(collections)))))
322+
323+
result = runner.invoke(
324+
['discover'],
325+
input='y\n' * 2 * (len(collections) + 1)
326+
)
327+
assert not result.exception, result.output
328+
329+
result = runner.invoke(
330+
['sync'] + ['foobar/' + x for x in collections]
331+
)
332+
assert not result.exception, result.output
333+
334+
assert {x.basename for x in tmpdir.join('foo').listdir()} == \
335+
{x.basename for x in tmpdir.join('bar').listdir()}
328336

329337

330338
def test_ident_conflict(tmpdir, runner):

0 commit comments

Comments
 (0)