/usr/lib/python2.7/dist-packages/smmap/test/lib.py is in python-smmap 0.9.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | """Provide base classes for the test system"""
from unittest import TestCase
import os
import tempfile
__all__ = ['TestBase', 'FileCreator']
#{ Utilities
class FileCreator(object):
"""A instance which creates a temporary file with a prefix and a given size
and provides this info to the user.
Once it gets deleted, it will remove the temporary file as well."""
__slots__ = ("_size", "_path")
def __init__(self, size, prefix=''):
assert size, "Require size to be larger 0"
self._path = tempfile.mktemp(prefix=prefix)
self._size = size
fp = open(self._path, "wb")
fp.seek(size - 1)
fp.write(b'1')
fp.close()
assert os.path.getsize(self.path) == size
def __del__(self):
try:
os.remove(self.path)
except OSError:
pass
# END exception handling
@property
def path(self):
return self._path
@property
def size(self):
return self._size
#} END utilities
class TestBase(TestCase):
"""Foundation used by all tests"""
#{ Configuration
k_window_test_size = 1000 * 1000 * 8 + 5195
#} END configuration
#{ Overrides
@classmethod
def setUpAll(cls):
# nothing for now
pass
# END overrides
#{ Interface
#} END interface
|