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
The Tor Project
Network Health
sbws
Commits
89ed8ace
Commit
89ed8ace
authored
Jun 25, 2018
by
juga
Committed by
Matt Traudt
Jul 03, 2018
Browse files
Add fixtures for unit tests
parent
666b9d7f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/conftest.py
View file @
89ed8ace
...
...
@@ -2,7 +2,7 @@ from sbws.lib.resultdump import ResultError
from
sbws.lib.resultdump
import
ResultSuccess
from
sbws.lib.resultdump
import
Result
from
sbws.lib.resultdump
import
write_result_to_datadir
from
sbws.util.config
import
get_config
from
sbws.util.config
import
get_config
,
_get_default_config
from
sbws.util.parser
import
create_parser
import
sbws.core.init
from
tempfile
import
TemporaryDirectory
...
...
@@ -50,6 +50,39 @@ def datadir(request):
return
D
(
request
.
fspath
.
dirpath
(
"data"
))
@
pytest
.
fixture
def
tmpdir
(
tmpdir_factory
,
request
):
"""Create a tmp dir for the tests"""
base
=
str
(
hash
(
request
.
node
.
nodeid
))[:
3
]
bn
=
tmpdir_factory
.
mktemp
(
base
)
return
bn
@
pytest
.
fixture
def
tmpdir_sbwshome
(
tmpdir
):
"""Create .sbws inside of the tests tmp dir"""
home
=
tmpdir
.
join
(
'.sbws'
)
os
.
makedirs
(
home
.
strpath
,
exist_ok
=
True
)
return
home
@
pytest
.
fixture
()
def
unittest_args
(
tmpdir_sbwshome
,
parser
):
"""Args with sbws home in the tests tmp dir"""
return
_PseudoArguments
(
directory
=
tmpdir_sbwshome
.
strpath
,
output
=
tmpdir_sbwshome
.
strpath
,
scale
=
False
)
@
pytest
.
fixture
()
def
unittest_conf
(
tmpdir_sbwshome
):
"""Default configuration with sbws home in the tmp test dir"""
conf
=
_get_default_config
()
conf
[
'paths'
][
'sbwshome'
]
=
tmpdir_sbwshome
.
strpath
conf
[
'paths'
][
'started_filepath'
]
=
""
return
conf
@
pytest
.
fixture
(
scope
=
'session'
)
def
parser
():
return
create_parser
()
...
...
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