Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-objstorage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-objstorage
Commits
289f9709
Commit
289f9709
authored
4 years ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Patches
Plain Diff
Replace manual pytest.raises mangling with the match argument
parent
b78406dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!74
Deprecate the `args` argument to get_objstorage in favor of kwargs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/objstorage/tests/test_server.py
+5
-15
5 additions, 15 deletions
swh/objstorage/tests/test_server.py
with
5 additions
and
15 deletions
swh/objstorage/tests/test_server.py
+
5
−
15
View file @
289f9709
...
...
@@ -35,38 +35,30 @@ def prepare_config_file(tmpdir, content, name="config.yml"):
def
test_load_and_check_config_no_configuration
():
"""
Inexistent configuration files raises
"""
with
pytest
.
raises
(
EnvironmentError
)
as
e
:
with
pytest
.
raises
(
EnvironmentError
,
match
=
"
Configuration file must be defined
"
)
:
load_and_check_config
(
None
)
assert
e
.
value
.
args
[
0
]
==
"
Configuration file must be defined
"
config_path
=
"
/indexer/inexistent/config.yml
"
with
pytest
.
raises
(
FileNotFoundError
)
as
e
:
with
pytest
.
raises
(
FileNotFoundError
,
match
=
f
"
{
config_path
}
does not exist
"
)
:
load_and_check_config
(
config_path
)
assert
e
.
value
.
args
[
0
]
==
"
Configuration file %s does not exist
"
%
(
config_path
,)
def
test_load_and_check_config_invalid_configuration_toplevel
(
tmpdir
):
"""
Invalid configuration raises
"""
config
=
{
"
something
"
:
"
useless
"
}
config_path
=
prepare_config_file
(
tmpdir
,
content
=
config
)
with
pytest
.
raises
(
KeyError
)
as
e
:
with
pytest
.
raises
(
KeyError
,
match
=
"
missing objstorage config entry
"
)
:
load_and_check_config
(
config_path
)
assert
e
.
value
.
args
[
0
]
==
"
Invalid configuration; missing objstorage config entry
"
def
test_load_and_check_config_invalid_configuration
(
tmpdir
):
"""
Invalid configuration raises
"""
config_path
=
prepare_config_file
(
tmpdir
,
content
=
{
"
objstorage
"
:
{
"
something
"
:
"
useless
"
}}
)
with
pytest
.
raises
(
KeyError
)
as
e
:
with
pytest
.
raises
(
KeyError
,
match
=
"
missing cls config entry
"
)
:
load_and_check_config
(
config_path
)
assert
"
missing cls config entry
"
in
e
.
value
.
args
[
0
]
def
test_load_and_check_config_invalid_configuration_level2
(
tmpdir
):
"""
Invalid configuration at 2nd level raises
"""
...
...
@@ -81,11 +73,9 @@ def test_load_and_check_config_invalid_configuration_level2(tmpdir):
c
=
copy
.
deepcopy
(
config
)
c
[
"
objstorage
"
][
"
args
"
].
pop
(
key
)
config_path
=
prepare_config_file
(
tmpdir
,
c
)
with
pytest
.
raises
(
KeyError
)
as
e
:
with
pytest
.
raises
(
KeyError
,
match
=
f
"
missing
{
key
}
config entry
"
)
:
load_and_check_config
(
config_path
)
assert
"
missing %s config entry
"
%
key
in
e
.
value
.
args
[
0
]
def
test_load_and_check_config_fine
(
tmpdir
):
"""
pathslicing configuration fine loads ok
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment