1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 16:49:42 +00:00

improve tests

This commit is contained in:
deadc0de6
2018-11-15 18:45:57 +01:00
parent ba31a9ad93
commit 0d407337ea
3 changed files with 12 additions and 4 deletions

View File

@@ -38,7 +38,8 @@ def get_tempdir():
return tempfile.mkdtemp(suffix=TMPSUFFIX)
def create_random_file(directory, content=None, binary=False):
def create_random_file(directory, content=None,
binary=False, template=False):
'''Create a new file in directory with random content.'''
fname = get_string(8)
mode = 'w'
@@ -46,9 +47,15 @@ def create_random_file(directory, content=None, binary=False):
mode = 'wb'
if content is None:
if binary:
content = bytes(get_string(100), 'ascii')
pre = bytes()
if template:
pre = bytes('{{@@ header() @@}}\n', 'ascii')
content = bytes('{}{}\n'.format(pre, get_string(100)), 'ascii')
else:
content = get_string(100)
pre = ''
if template:
pre = '{{@@ header() @@}}\n'
content = '{}{}\n'.format(pre, get_string(100))
path = os.path.join(directory, fname)
with open(path, mode) as f:
f.write(content)

View File

@@ -100,6 +100,7 @@ class TestCompare(unittest.TestCase):
create=self.CONFIG_CREATE)
self.assertTrue(os.path.exists(confpath))
conf, opts = load_config(confpath, profile)
opts['longkey'] = True
dfiles = [d1, d2, d3, d4, d5]
# import the files

View File

@@ -119,7 +119,7 @@ exec bspwm
self.addCleanup(clean, dir1)
dst6 = os.path.join(dst, get_string(6))
# fill with files
sub1, _ = create_random_file(dir1)
sub1, _ = create_random_file(dir1, template=True)
self.assertTrue(os.path.exists(sub1))
sub2, _ = create_random_file(dir1)
self.assertTrue(os.path.exists(sub2))