mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 07:43:59 +00:00
adding binaries in tests
This commit is contained in:
@@ -36,13 +36,19 @@ def get_tempfolder():
|
||||
return tempfile.mkdtemp(suffix=TMPSUFFIX)
|
||||
|
||||
|
||||
def create_random_file(folder, content=None):
|
||||
def create_random_file(folder, content=None, binary=False):
|
||||
'''Create a new file in folder with random content.'''
|
||||
fname = get_string(8)
|
||||
mode = 'w'
|
||||
if binary:
|
||||
mode = 'wb'
|
||||
if content is None:
|
||||
content = get_string(100)
|
||||
if binary:
|
||||
content = bytes(get_string(100), 'ascii')
|
||||
else:
|
||||
content = get_string(100)
|
||||
path = os.path.join(folder, fname)
|
||||
with open(path, 'w') as f:
|
||||
with open(path, mode) as f:
|
||||
f.write(content)
|
||||
return path, content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user