Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
monkeysign
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
monkeysphere
monkeysign
Commits
7809eb58
Commit
7809eb58
authored
8 years ago
by
anarcat
Browse files
Options
Downloads
Patches
Plain Diff
try to establish a more standard way to disable network tests
parent
c3dd521b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
debian/rules
+2
-1
2 additions, 1 deletion
debian/rules
monkeysign/tests/test_network.py
+42
-2
42 additions, 2 deletions
monkeysign/tests/test_network.py
with
44 additions
and
3 deletions
debian/rules
+
2
−
1
View file @
7809eb58
...
@@ -6,7 +6,8 @@
...
@@ -6,7 +6,8 @@
# This has to be exported to make some magic below work.
# This has to be exported to make some magic below work.
export
DH_OPTIONS
export
DH_OPTIONS
export
UNITTEST_NO_NETWORK
=
1
# disable network tests in Debian package build
export
PYTEST_USENETWORK
=
no
%
:
%
:
dh
$@
--with
=
python2,sphinxdoc
--buildsystem
=
pybuild
dh
$@
--with
=
python2,sphinxdoc
--buildsystem
=
pybuild
...
...
This diff is collapsed.
Click to expand it.
monkeysign/tests/test_network.py
+
42
−
2
View file @
7809eb58
...
@@ -33,8 +33,48 @@ from test_lib import TestTimeLimit, AlarmException, find_test_file
...
@@ -33,8 +33,48 @@ from test_lib import TestTimeLimit, AlarmException, find_test_file
import
test_ui
import
test_ui
@unittest.skipIf
(
'
UNITTEST_NO_NETWORK
'
in
os
.
environ
,
'
network tests disabled
'
)
def
skipUnlessNetwork
():
"""
add a knob to disable network tests
to disable network tests, use PYTEST_USENETWORK=no. by default, it
is assumed there is network access.
this is mainly to deal with Debian packages that are built in
network-less chroots. unfortunately, there is no standard
environment in dpkg-buildpackage or ./debian/rules binary that we
can rely on to disable tests, so we revert to a custom variable
that can hopefully make it up to the pybuild toolchain
I looked at DEB_BUILD_OPTIONS=network, but that is not standard
and only mentionned once here:
https://lists.debian.org/debian-devel/2009/09/msg00992.html
DEB_BUILD_OPTIONS is also not set by default, so it
'
s not a good
way to detect Debian package builds
pbuilder uses USENETWORK=no/yes, schroot uses UNSHARE_NET, but
those are not standard either, see:
https://github.com/spotify/dh-virtualenv/issues/77
https://github.com/codelibre-net/schroot/blob/2e3d015a759d2b5106e851af34c8d5974d84f18e/lib/schroot/chroot/facet/unshare.cc
"""
# by default, we run network tests
skip
=
False
reason
=
''
if
'
PYTEST_USENETWORK
'
in
os
.
environ
:
skip
=
'
no
'
in
os
.
environ
.
get
(
'
PYTEST_USENETWORK
'
,
''
)
reason
=
'
PYTEST_USENETWORK=no specified in environment
'
if
skip
:
return
unittest
.
skip
(
'
network tests disabled (%s)
'
%
reason
)
else
:
return
lambda
func
:
func
@skipUnlessNetwork
()
class
TestGpgNetwork
(
TestTimeLimit
):
class
TestGpgNetwork
(
TestTimeLimit
):
"""
Separate test cases for functions that hit the network
"""
Separate test cases for functions that hit the network
each test needs to run under a specific timeout so we don
'
t wait on
each test needs to run under a specific timeout so we don
'
t wait on
...
@@ -67,7 +107,7 @@ the network forever"""
...
@@ -67,7 +107,7 @@ the network forever"""
del
self
.
gpg
del
self
.
gpg
@
unittest.skipIf
(
'
UNITTEST_NO_NETWORK
'
in
os
.
environ
,
'
network tests disabled
'
)
@
skipUnlessNetwork
(
)
class
KeyserverTests
(
test_ui
.
BaseTestCase
):
class
KeyserverTests
(
test_ui
.
BaseTestCase
):
args
=
[
'
--keyserver
'
,
'
pool.sks-keyservers.net
'
]
args
=
[
'
--keyserver
'
,
'
pool.sks-keyservers.net
'
]
pattern
=
'
7B75921E
'
pattern
=
'
7B75921E
'
...
...
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