Remove unittest inheritance

This commit is contained in:
Markus Unterwaditzer 2014-03-17 19:30:39 +01:00
parent 12c70ca573
commit 17f9ccc895
7 changed files with 19 additions and 18 deletions

View file

@ -11,6 +11,7 @@ from vdirsyncer.storage.base import Item
import vdirsyncer.exceptions as exceptions import vdirsyncer.exceptions as exceptions
from .. import assert_item_equals from .. import assert_item_equals
import random import random
import pytest
class StorageTests(object): class StorageTests(object):
@ -47,7 +48,8 @@ class StorageTests(object):
s = self._get_storage() s = self._get_storage()
item = self._create_bogus_item(1) item = self._create_bogus_item(1)
s.upload(item) s.upload(item)
self.assertRaises(exceptions.PreconditionFailed, s.upload, item) with pytest.raises(exceptions.PreconditionFailed):
s.upload(item)
def test_upload(self): def test_upload(self):
s = self._get_storage() s = self._get_storage()
@ -68,23 +70,24 @@ class StorageTests(object):
def test_update_nonexisting(self): def test_update_nonexisting(self):
s = self._get_storage() s = self._get_storage()
item = self._create_bogus_item(1) item = self._create_bogus_item(1)
self.assertRaises(exceptions.PreconditionFailed, with pytest.raises(exceptions.PreconditionFailed):
s.update, s._get_href('1'), item, 123) s.update(s._get_href('1'), item, 123)
self.assertRaises(exceptions.PreconditionFailed, with pytest.raises(exceptions.PreconditionFailed):
s.update, 'huehue', item, 123) s.update('huehue', item, 123)
def test_wrong_etag(self): def test_wrong_etag(self):
s = self._get_storage() s = self._get_storage()
obj = self._create_bogus_item(1) obj = self._create_bogus_item(1)
href, etag = s.upload(obj) href, etag = s.upload(obj)
self.assertRaises( with pytest.raises(exceptions.PreconditionFailed):
exceptions.PreconditionFailed, s.update, href, obj, 'lolnope') s.update(href, obj, 'lolnope')
self.assertRaises( with pytest.raises(exceptions.PreconditionFailed):
exceptions.PreconditionFailed, s.delete, href, 'lolnope') s.delete(href, 'lolnope')
def test_delete_nonexisting(self): def test_delete_nonexisting(self):
s = self._get_storage() s = self._get_storage()
self.assertRaises(exceptions.PreconditionFailed, s.delete, '1', 123) with pytest.raises(exceptions.PreconditionFailed):
s.delete('1', 123)
def test_list(self): def test_list(self):
s = self._get_storage() s = self._get_storage()

View file

@ -43,7 +43,7 @@ END:VEVENT
END:VCALENDAR''' END:VCALENDAR'''
class CaldavStorageTests(TestCase, DavStorageTests): class TestCaldavStorage(DavStorageTests):
storage_class = CaldavStorage storage_class = CaldavStorage
item_template = TASK_TEMPLATE item_template = TASK_TEMPLATE

View file

@ -14,7 +14,7 @@ from vdirsyncer.storage.dav.carddav import CarddavStorage
from . import DavStorageTests from . import DavStorageTests
class CarddavStorageTests(TestCase, DavStorageTests): class TestCarddavStorage(DavStorageTests):
storage_class = CarddavStorage storage_class = CarddavStorage
item_template = (u'BEGIN:VCARD\n' item_template = (u'BEGIN:VCARD\n'

View file

@ -8,7 +8,6 @@
:license: MIT, see LICENSE for more details. :license: MIT, see LICENSE for more details.
''' '''
from unittest import TestCase
import pytest import pytest
import os import os
from vdirsyncer.storage.filesystem import FilesystemStorage from vdirsyncer.storage.filesystem import FilesystemStorage
@ -16,7 +15,7 @@ from . import StorageTests
@pytest.mark.usefixtures('class_tmpdir') @pytest.mark.usefixtures('class_tmpdir')
class FilesystemStorageTests(TestCase, StorageTests): class TestFilesystemStorage(StorageTests):
storage_class = FilesystemStorage storage_class = FilesystemStorage
def get_storage_args(self, collection=None): def get_storage_args(self, collection=None):

View file

@ -14,7 +14,7 @@ from textwrap import dedent
from vdirsyncer.storage.http import HttpStorage, Item from vdirsyncer.storage.http import HttpStorage, Item
class HttpStorageTests(TestCase): class TestHttpStorage(object):
def test_list(self): def test_list(self):
collection_url = 'http://127.0.0.1/calendar/collection/' collection_url = 'http://127.0.0.1/calendar/collection/'

View file

@ -13,7 +13,7 @@ from vdirsyncer.storage.memory import MemoryStorage
from . import StorageTests from . import StorageTests
class MemoryStorageTests(TestCase, StorageTests): class TestMemoryStorage(StorageTests):
storage_class = MemoryStorage storage_class = MemoryStorage

View file

@ -7,10 +7,9 @@
:license: MIT, see LICENSE for more details. :license: MIT, see LICENSE for more details.
''' '''
from unittest import TestCase
import vdirsyncer.cli as cli import vdirsyncer.cli as cli
import vdirsyncer.exceptions as exceptions import vdirsyncer.exceptions as exceptions
class CliTests(TestCase): class TestCli(object):
pass pass