From 3deba27d8b36bdcef61c9a7314f22607c9cedea7 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Mon, 15 Aug 2016 11:25:37 +0200 Subject: [PATCH] Make test_collection_arg more generic --- tests/storage/__init__.py | 14 +++++++++----- tests/storage/test_http_with_singlefile.py | 3 +++ tests/storage/test_singlefile.py | 4 ---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index 86e0626..1dd93e7 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -208,11 +208,15 @@ class StorageTests(object): assert 'collection argument must not be given' in str(excinfo.value) - def test_collection_arg(self, requires_collections, get_storage_args): - s = self.storage_class(**get_storage_args(collection='test2')) - # Can't do stronger assertion because of radicale, which needs a - # fileextension to guess the collection type. - assert 'test2' in s.collection + def test_collection_arg(self, get_storage_args): + if self.supports_collections: + s = self.storage_class(**get_storage_args(collection='test2')) + # Can't do stronger assertion because of radicale, which needs a + # fileextension to guess the collection type. + assert 'test2' in s.collection + else: + with pytest.raises(ValueError): + self.storage_class(**get_storage_args(), collection='ayy') def test_case_sensitive_uids(self, s, get_item): if s.storage_name == 'filesystem': diff --git a/tests/storage/test_http_with_singlefile.py b/tests/storage/test_http_with_singlefile.py index fa0fac2..554bcf3 100644 --- a/tests/storage/test_http_with_singlefile.py +++ b/tests/storage/test_http_with_singlefile.py @@ -17,6 +17,9 @@ class CombinedStorage(Storage): _repr_attributes = ('url', 'path') def __init__(self, url, path, **kwargs): + if kwargs.get('collection', None) is not None: + raise ValueError() + super(CombinedStorage, self).__init__(**kwargs) self.url = url self.path = path diff --git a/tests/storage/test_singlefile.py b/tests/storage/test_singlefile.py index b2be4ee..da0d59b 100644 --- a/tests/storage/test_singlefile.py +++ b/tests/storage/test_singlefile.py @@ -23,7 +23,3 @@ class TestSingleFileStorage(StorageTests): kwargs.update(path=self._path) return kwargs return inner - - def test_collection_arg(self, tmpdir): - with pytest.raises(ValueError): - self.storage_class(str(tmpdir.join('foo.ics')), collection='ha')