Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.core
Commits
d637ac60
Commit
d637ac60
authored
Sep 26, 2018
by
Samuel GAIST
Browse files
[test][utils] Add random id generator
parent
befb6184
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/core/test/utils.py
View file @
d637ac60
...
...
@@ -30,6 +30,8 @@
import
os
import
shutil
import
string
import
random
import
nose
...
...
@@ -161,3 +163,13 @@ def cleanup():
shutil
.
copymode
(
tmp_prefix
,
tmp_prefix
+
'.new'
)
shutil
.
rmtree
(
tmp_prefix
)
shutil
.
move
(
tmp_prefix
+
'.new'
,
tmp_prefix
)
#----------------------------------------------------------
def
id_generator
(
size
=
6
,
chars
=
string
.
ascii_uppercase
+
string
.
digits
):
""" Simple id generator based on
https://stackoverflow.com/a/2257449/5843716
"""
return
''
.
join
(
random
.
choice
(
chars
)
for
_
in
range
(
size
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment