Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Renaud Boyer
swh-model
Commits
27a05d68
Commit
27a05d68
authored
3 years ago
by
vlorentz
Browse files
Options
Downloads
Patches
Plain Diff
tox: Check swh-identify can run even if Dulwich isn't installed
parent
c62f13fd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
pytest.ini
+1
-0
1 addition, 0 deletions
pytest.ini
requirements-test.txt
+0
-1
0 additions, 1 deletion
requirements-test.txt
setup.py
+1
-0
1 addition, 0 deletions
setup.py
swh/model/tests/test_cli.py
+15
-0
15 additions, 0 deletions
swh/model/tests/test_cli.py
tox.ini
+11
-11
11 additions, 11 deletions
tox.ini
with
28 additions
and
12 deletions
pytest.ini
+
1
−
0
View file @
27a05d68
...
...
@@ -3,3 +3,4 @@ addopts = --doctest-modules -p no:pytest_swh_core
norecursedirs
=
docs .*
markers
=
fs:
tests
that
involve
filesystem
ios
requires_optional_deps:
tests
in
test_cli.py
that
should
not
run
if
optional
dependencies
are
not
installed
This diff is collapsed.
Click to expand it.
requirements-test.txt
+
0
−
1
View file @
27a05d68
Click
dulwich
pytest
pytz
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
27a05d68
...
...
@@ -54,6 +54,7 @@ setup(
),
extras_require
=
{
"
cli
"
:
parse_requirements
(
"
cli
"
),
"
testing-minimal
"
:
parse_requirements
(
"
test
"
),
"
testing
"
:
parse_requirements
(
"
test
"
)
+
parse_requirements
(
"
cli
"
),
},
include_package_data
=
True
,
...
...
This diff is collapsed.
Click to expand it.
swh/model/tests/test_cli.py
+
15
−
0
View file @
27a05d68
...
...
@@ -4,9 +4,11 @@
# See top-level LICENSE file for more information
import
os
import
sys
import
tarfile
import
tempfile
import
unittest
import
unittest.mock
from
click.testing
import
CliRunner
import
pytest
...
...
@@ -52,6 +54,7 @@ class TestIdentify(DataMixin, unittest.TestCase):
result
=
self
.
runner
.
invoke
(
cli
.
identify
,
[
"
--type
"
,
"
directory
"
,
path
])
self
.
assertSWHID
(
result
,
"
swh:1:dir:e8b0f1466af8608c8a3fb9879db172b887e80759
"
)
@pytest.mark.requires_optional_deps
def
test_snapshot_id
(
self
):
"""
identify a snapshot
"""
tarball
=
os
.
path
.
join
(
...
...
@@ -68,6 +71,18 @@ class TestIdentify(DataMixin, unittest.TestCase):
result
,
"
swh:1:snp:abc888898124270905a0ef3c67e872ce08e7e0c1
"
)
def
test_snapshot_without_dulwich
(
self
):
"""
checks swh-identify returns a
'
nice
'
message instead of a traceback
when dulwich is not installed
"""
with
unittest
.
mock
.
patch
.
dict
(
sys
.
modules
,
{
"
dulwich
"
:
None
}):
with
tempfile
.
TemporaryDirectory
(
prefix
=
"
swh.model.cli
"
)
as
d
:
result
=
self
.
runner
.
invoke
(
cli
.
identify
,
[
"
--type
"
,
"
snapshot
"
,
d
],
catch_exceptions
=
False
,
)
assert
result
.
exit_code
==
1
assert
"'
swh.model[cli]
'"
in
result
.
output
def
test_origin_id
(
self
):
"""
identify an origin URL
"""
url
=
"
https://github.com/torvalds/linux
"
...
...
This diff is collapsed.
Click to expand it.
tox.ini
+
11
−
11
View file @
27a05d68
[tox]
envlist
=
black,flake8,mypy,py3
,identify
envlist
=
black,flake8,mypy,py3
-{minimal,full}
[testenv]
extras
=
testing
full:
testing
minimal:
testing-minimal
deps
=
pytest-cov
commands
=
pytest
--cov
=
{envsitepackagesdir}/swh/model
\
--doctest-modules
\
{envsitepackagesdir}/swh/model
\
--cov-branch {posargs}
full: {envsitepackagesdir}/swh/model
\
minimal: {envsitepackagesdir}/swh/model/tests/test_cli.py -m 'not requires_optional_deps'
\
--cov-branch {posargs}
[testenv:identify]
# no 'extras = testing', as it would install swh-core;
# and this test is designed to check 'swh-identify' does not depend on swh-core.
extras
=
deps
=
-r
requirements-test.txt
[testenv:py3]
skip_install
=
true
deps
=
tox
commands
=
pytest
{envsitepackagesdir}/swh/model/tests/test_cli.py
tox
-e
py3-full
--
{posargs}
tox
-e
py3-minimal
--
{posargs}
[testenv:black]
skip_install
=
true
...
...
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