mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 11:14:17 +00:00
improve tests
This commit is contained in:
@@ -38,7 +38,8 @@ def get_tempdir():
|
|||||||
return tempfile.mkdtemp(suffix=TMPSUFFIX)
|
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.'''
|
'''Create a new file in directory with random content.'''
|
||||||
fname = get_string(8)
|
fname = get_string(8)
|
||||||
mode = 'w'
|
mode = 'w'
|
||||||
@@ -46,9 +47,15 @@ def create_random_file(directory, content=None, binary=False):
|
|||||||
mode = 'wb'
|
mode = 'wb'
|
||||||
if content is None:
|
if content is None:
|
||||||
if binary:
|
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:
|
else:
|
||||||
content = get_string(100)
|
pre = ''
|
||||||
|
if template:
|
||||||
|
pre = '{{@@ header() @@}}\n'
|
||||||
|
content = '{}{}\n'.format(pre, get_string(100))
|
||||||
path = os.path.join(directory, fname)
|
path = os.path.join(directory, fname)
|
||||||
with open(path, mode) as f:
|
with open(path, mode) as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ class TestCompare(unittest.TestCase):
|
|||||||
create=self.CONFIG_CREATE)
|
create=self.CONFIG_CREATE)
|
||||||
self.assertTrue(os.path.exists(confpath))
|
self.assertTrue(os.path.exists(confpath))
|
||||||
conf, opts = load_config(confpath, profile)
|
conf, opts = load_config(confpath, profile)
|
||||||
|
opts['longkey'] = True
|
||||||
dfiles = [d1, d2, d3, d4, d5]
|
dfiles = [d1, d2, d3, d4, d5]
|
||||||
|
|
||||||
# import the files
|
# import the files
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ exec bspwm
|
|||||||
self.addCleanup(clean, dir1)
|
self.addCleanup(clean, dir1)
|
||||||
dst6 = os.path.join(dst, get_string(6))
|
dst6 = os.path.join(dst, get_string(6))
|
||||||
# fill with files
|
# fill with files
|
||||||
sub1, _ = create_random_file(dir1)
|
sub1, _ = create_random_file(dir1, template=True)
|
||||||
self.assertTrue(os.path.exists(sub1))
|
self.assertTrue(os.path.exists(sub1))
|
||||||
sub2, _ = create_random_file(dir1)
|
sub2, _ = create_random_file(dir1)
|
||||||
self.assertTrue(os.path.exists(sub2))
|
self.assertTrue(os.path.exists(sub2))
|
||||||
|
|||||||
Reference in New Issue
Block a user