Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
b36b7a81
Commit
b36b7a81
authored
May 23, 2019
by
Samuel GAIST
Browse files
[test][conftest] Move prefix sync and cleanup to their own function
This will allow to refresh the prefix content if needed.
parent
f4acc75b
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/test/conftest.py
View file @
b36b7a81
...
...
@@ -49,15 +49,9 @@ prefix = os.path.join(prefix_folder, "prefix")
environment_file
=
os
.
path
.
join
(
prefix
,
"environment.json"
)
@
pytest
.
fixture
(
scope
=
"module"
,
params
=
[
item
for
item
in
AssetType
if
item
is
not
AssetType
.
UNKNOWN
]
)
def
asset_type
(
request
):
return
request
.
param
def
sync_prefix
():
"""Copy the content of the various package test prefixes in the running test prefix"""
@
pytest
.
fixture
(
scope
=
"module"
)
def
test_prefix
():
prefixes
=
[
pkg_resources
.
resource_filename
(
"beat.backend.python.test"
,
"prefix"
),
pkg_resources
.
resource_filename
(
"beat.core.test"
,
"prefix"
),
...
...
@@ -66,17 +60,9 @@ def test_prefix():
for
path
in
prefixes
:
subprocess
.
check_call
([
"rsync"
,
"-arz"
,
path
,
prefix_folder
])
with
open
(
environment_file
,
"wt"
)
as
env_file
:
env_file
.
write
(
json
.
dumps
(
{
"Test Env"
:
{
"name"
:
"Python 2.7"
,
"version"
:
"1.3.0"
},
"Another test Env"
:
{
"name"
:
"another test"
,
"version"
:
"1.1.1"
},
}
)
)
yield
prefix
def
clean_prefix
():
"""Removes the content of the test prefix(s)"""
shutil
.
rmtree
(
prefix_folder
)
...
...
@@ -93,6 +79,32 @@ def test_prefix():
pass
@
pytest
.
fixture
(
scope
=
"module"
,
params
=
[
item
for
item
in
AssetType
if
item
is
not
AssetType
.
UNKNOWN
]
)
def
asset_type
(
request
):
return
request
.
param
@
pytest
.
fixture
(
scope
=
"module"
)
def
test_prefix
():
sync_prefix
()
with
open
(
environment_file
,
"wt"
)
as
env_file
:
env_file
.
write
(
json
.
dumps
(
{
"Test Env"
:
{
"name"
:
"Python 2.7"
,
"version"
:
"1.3.0"
},
"Another test Env"
:
{
"name"
:
"another test"
,
"version"
:
"1.1.1"
},
}
)
)
yield
prefix
clean_prefix
()
@
pytest
.
fixture
(
scope
=
"module"
)
def
beat_context
(
test_prefix
):
Context
=
namedtuple
(
"Context"
,
[
"meta"
])
...
...
Write
Preview
Supports
Markdown
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