Browse Source

rename test base class

Thomas Waldmann 10 years ago
parent
commit
0b3710be22

+ 1 - 1
attic/testsuite/__init__.py

@@ -32,7 +32,7 @@ has_mtime_ns = sys.version >= '3.3'
 utime_supports_fd = os.utime in getattr(os, 'supports_fd', {})
 
 
-class AtticTestCase(unittest.TestCase):
+class BaseTestCase(unittest.TestCase):
     """
     """
     assert_in = unittest.TestCase.assertIn

+ 4 - 4
attic/testsuite/archive.py

@@ -1,5 +1,5 @@
 import msgpack
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 from attic.testsuite.mock import Mock
 from attic.archive import Archive, CacheChunkBuffer, RobustUnpacker
 from attic.key import PlaintextKey
@@ -17,7 +17,7 @@ class MockCache:
         return id, len(data), len(data)
 
 
-class ArchiveTimestampTestCase(AtticTestCase):
+class ArchiveTimestampTestCase(BaseTestCase):
 
     def _test_timestamp_parsing(self, isoformat, expected):
         repository = Mock()
@@ -38,7 +38,7 @@ class ArchiveTimestampTestCase(AtticTestCase):
             datetime(1970, 1, 1, 0, 0, 1, 0, timezone.utc))
 
 
-class ChunkBufferTestCase(AtticTestCase):
+class ChunkBufferTestCase(BaseTestCase):
 
     def test(self):
         data = [{b'foo': 1}, {b'bar': 2}]
@@ -56,7 +56,7 @@ class ChunkBufferTestCase(AtticTestCase):
         self.assert_equal(data, list(unpacker))
 
 
-class RobustUnpackerTestCase(AtticTestCase):
+class RobustUnpackerTestCase(BaseTestCase):
 
     def make_chunks(self, items):
         return b''.join(msgpack.packb({'path': item}) for item in items)

+ 2 - 2
attic/testsuite/archiver.py

@@ -18,7 +18,7 @@ from attic.crypto import bytes_to_long, num_aes_blocks
 from attic.helpers import Manifest
 from attic.remote import RemoteRepository, PathNotAllowed
 from attic.repository import Repository
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 from attic.testsuite.mock import patch
 
 try:
@@ -60,7 +60,7 @@ class environment_variable:
                 os.environ[k] = v
 
 
-class ArchiverTestCaseBase(AtticTestCase):
+class ArchiverTestCaseBase(BaseTestCase):
 
     prefix = ''
 

+ 2 - 2
attic/testsuite/chunker.py

@@ -1,10 +1,10 @@
 from attic.chunker import Chunker, buzhash, buzhash_update
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 from attic.archive import CHUNK_MAX
 from io import BytesIO
 
 
-class ChunkerTestCase(AtticTestCase):
+class ChunkerTestCase(BaseTestCase):
 
     def test_chunkify(self):
         data = b'0' * int(1.5 * CHUNK_MAX) + b'Y'

+ 2 - 2
attic/testsuite/crypto.py

@@ -1,9 +1,9 @@
 from binascii import hexlify
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 from attic.crypto import AES, bytes_to_long, bytes_to_int, long_to_bytes, pbkdf2_sha256, get_random_bytes
 
 
-class CryptoTestCase(AtticTestCase):
+class CryptoTestCase(BaseTestCase):
 
     def test_bytes_to_int(self):
         self.assert_equal(bytes_to_int(b'\0\0\0\1'), 1)

+ 2 - 2
attic/testsuite/hashindex.py

@@ -2,10 +2,10 @@ import hashlib
 import os
 import tempfile
 from attic.hashindex import NSIndex, ChunkIndex
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 
 
-class HashIndexTestCase(AtticTestCase):
+class HashIndexTestCase(BaseTestCase):
 
     def _generic_test(self, cls, make_value, sha):
         idx = cls()

+ 11 - 11
attic/testsuite/helpers.py

@@ -6,11 +6,11 @@ import tempfile
 import unittest
 from attic.helpers import adjust_patterns, exclude_path, Location, format_timedelta, IncludePattern, ExcludePattern, make_path_safe, UpgradableLock, prune_within, prune_split, to_localtime, \
     StableDict, int_to_bigint, bigint_to_int, parse_timestamp
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 import msgpack
 
 
-class BigIntTestCase(AtticTestCase):
+class BigIntTestCase(BaseTestCase):
 
     def test_bigint(self):
         self.assert_equal(int_to_bigint(0), 0)
@@ -22,7 +22,7 @@ class BigIntTestCase(AtticTestCase):
         self.assert_equal(bigint_to_int(int_to_bigint(2**70)), 2**70)
 
 
-class LocationTestCase(AtticTestCase):
+class LocationTestCase(BaseTestCase):
 
     def test(self):
         self.assert_equal(
@@ -60,7 +60,7 @@ class LocationTestCase(AtticTestCase):
                               Location(Location(location).canonical_path()).canonical_path())
 
 
-class FormatTimedeltaTestCase(AtticTestCase):
+class FormatTimedeltaTestCase(BaseTestCase):
 
     def test(self):
         t0 = datetime(2001, 1, 1, 10, 20, 3, 0)
@@ -71,7 +71,7 @@ class FormatTimedeltaTestCase(AtticTestCase):
         )
 
 
-class PatternTestCase(AtticTestCase):
+class PatternTestCase(BaseTestCase):
 
     files = [
         '/etc/passwd', '/etc/hosts', '/home',
@@ -104,7 +104,7 @@ class PatternTestCase(AtticTestCase):
                           ['/etc/passwd', '/etc/hosts', '/var/log/messages', '/var/log/dmesg'])
 
 
-class MakePathSafeTestCase(AtticTestCase):
+class MakePathSafeTestCase(BaseTestCase):
 
     def test(self):
         self.assert_equal(make_path_safe('/foo/bar'), 'foo/bar')
@@ -116,7 +116,7 @@ class MakePathSafeTestCase(AtticTestCase):
         self.assert_equal(make_path_safe('/'), '.')
         self.assert_equal(make_path_safe('/'), '.')
 
-class UpgradableLockTestCase(AtticTestCase):
+class UpgradableLockTestCase(BaseTestCase):
 
     def test(self):
         file = tempfile.NamedTemporaryFile()
@@ -143,7 +143,7 @@ class MockArchive:
         return repr(self.ts)
 
 
-class PruneSplitTestCase(AtticTestCase):
+class PruneSplitTestCase(BaseTestCase):
 
     def test(self):
 
@@ -172,7 +172,7 @@ class PruneSplitTestCase(AtticTestCase):
         dotest(test_archives, 0, [], [])
 
 
-class PruneWithinTestCase(AtticTestCase):
+class PruneWithinTestCase(BaseTestCase):
 
     def test(self):
 
@@ -203,7 +203,7 @@ class PruneWithinTestCase(AtticTestCase):
         dotest(test_archives, '1y',  [0, 1, 2, 3, 4, 5])
 
 
-class StableDictTestCase(AtticTestCase):
+class StableDictTestCase(BaseTestCase):
 
     def test(self):
         d = StableDict(foo=1, bar=2, boo=3, baz=4)
@@ -211,7 +211,7 @@ class StableDictTestCase(AtticTestCase):
         self.assert_equal(hashlib.md5(msgpack.packb(d)).hexdigest(), 'fc78df42cd60691b3ac3dd2a2b39903f')
 
 
-class TestParseTimestamp(AtticTestCase):
+class TestParseTimestamp(BaseTestCase):
 
     def test(self):
         self.assert_equal(parse_timestamp('2015-04-19T20:25:00.226410'), datetime(2015, 4, 19, 20, 25, 0, 226410, timezone.utc))

+ 2 - 2
attic/testsuite/key.py

@@ -4,12 +4,12 @@ import shutil
 import tempfile
 from binascii import hexlify
 from attic.crypto import bytes_to_long, num_aes_blocks
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 from attic.key import PlaintextKey, PassphraseKey, KeyfileKey
 from attic.helpers import Location, unhexlify
 
 
-class KeyTestCase(AtticTestCase):
+class KeyTestCase(BaseTestCase):
 
     class MockArgs:
         repository = Location(tempfile.mkstemp()[1])

+ 2 - 2
attic/testsuite/lrucache.py

@@ -1,8 +1,8 @@
 from attic.lrucache import LRUCache
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 
 
-class LRUCacheTestCase(AtticTestCase):
+class LRUCacheTestCase(BaseTestCase):
 
     def test(self):
         c = LRUCache(2)

+ 3 - 3
attic/testsuite/platform.py

@@ -4,7 +4,7 @@ import sys
 import tempfile
 import unittest
 from attic.platform import acl_get, acl_set
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 
 
 ACCESS_ACL = """
@@ -36,7 +36,7 @@ def fakeroot_detected():
 
 @unittest.skipUnless(sys.platform.startswith('linux'), 'linux only test')
 @unittest.skipIf(fakeroot_detected(), 'not compatible with fakeroot')
-class PlatformLinuxTestCase(AtticTestCase):
+class PlatformLinuxTestCase(BaseTestCase):
 
     def setUp(self):
         self.tmpdir = tempfile.mkdtemp()
@@ -74,7 +74,7 @@ class PlatformLinuxTestCase(AtticTestCase):
 
 @unittest.skipUnless(sys.platform.startswith('darwin'), 'OS X only test')
 @unittest.skipIf(fakeroot_detected(), 'not compatible with fakeroot')
-class PlatformDarwinTestCase(AtticTestCase):
+class PlatformDarwinTestCase(BaseTestCase):
 
     def setUp(self):
         self.tmpdir = tempfile.mkdtemp()

+ 3 - 2
attic/testsuite/repository.py

@@ -6,10 +6,11 @@ from attic.hashindex import NSIndex
 from attic.helpers import Location, IntegrityError, UpgradableLock
 from attic.remote import RemoteRepository, InvalidRPCMethod
 from attic.repository import Repository
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 
 
-class RepositoryTestCaseBase(AtticTestCase):
+class RepositoryTestCaseBase(BaseTestCase):
+    key_size = 32
 
     def open(self, create=False):
         return Repository(os.path.join(self.tmppath, 'repository'), create=create)

+ 2 - 2
attic/testsuite/xattr.py

@@ -1,12 +1,12 @@
 import os
 import tempfile
 import unittest
-from attic.testsuite import AtticTestCase
+from attic.testsuite import BaseTestCase
 from attic.xattr import is_enabled, getxattr, setxattr, listxattr
 
 
 @unittest.skipUnless(is_enabled(), 'xattr not enabled on filesystem')
-class XattrTestCase(AtticTestCase):
+class XattrTestCase(BaseTestCase):
 
     def setUp(self):
         self.tmpfile = tempfile.NamedTemporaryFile()