Page MenuHomeSoftware Heritage

swh-vault's unit tests are broken on jenkins
Closed, ResolvedPublic


with eg.

_______________ ERROR collecting swh/vault/tests/ _______________
ImportError while importing test module '/home/jenkins/workspace/DVAU/tests/swh/vault/tests/'.
Hint: make sure your test modules/packages have valid Python names.
swh/vault/tests/ in <module>
    from swh.vault.tests.vault_testing import VaultTestFixture, hash_content
swh/vault/tests/ in <module>
    from import StorageTestFixture
.tox/py3/lib/python3.5/site-packages/swh/storage/tests/ in <module>
    from hypothesis.strategies import (binary, composite, sets)
E   ImportError: No module named 'hypothesis'

So the question is now: should hypothesis be in storage's requirements.txt instead of requirements-tests.txt?

Event Timeline

douardda created this task.Nov 19 2018, 9:43 AM
douardda triaged this task as High priority.
ardumont added a comment.EditedNov 19 2018, 10:22 AM

Hypothesis is a test requirements from storage.
The vault uses the storage's fixture (which now requires as test hypothesis but not for everything)
Hypothesis is not used by the vault so that fails here.

So i see 3 solutions:

  1. move the data generation to another module (as this won't be transitively required by the vault, that won't break) -> seems the right call as this does not need to be opened if not needed
  2. add the hypothesis in the vault's requirements-test.txt -> that's a workaround that won't impede that pattern to be reproduced elsewhere
  3. add hypothesis in the storage's requirements (as you proposed) -> That could solve the problem and not draw the caveat of 2. I'm not sure whether the data generation should say in the storage though... (but yagni for now ;) That data is representing our model, so it could be either in the model or in the core (centralized test fixtures are usually there)...

I think the more reasonable approach for now is 1 and won't impede 3 to be done if that needs to.

What do you think?

Or a fourth solution:

  1. make the setup add all [testing] version of swh.* dependency, something like:
diff --git a/ b/
index 7efe02b..e62be82 100755
--- a/
+++ b/
@@ -8,6 +8,8 @@ from setuptools import setup, find_packages
 from os import path
 from io import open
+import re
 here = path.abspath(path.dirname(__file__))
@@ -16,7 +18,7 @@ with open(path.join(here, ''), encoding='utf-8') as f:
     long_description =
-def parse_requirements(name=None):
+def parse_requirements(name=None, env=None):
     if name:
         reqf = 'requirements-%s.txt' % name
@@ -31,6 +33,9 @@ def parse_requirements(name=None):
             line = line.strip()
             if not line or line.startswith('#'):
+            if env is not None:
+                line = re.sub(r'^([^ <>=!]+)(.*)$',
+                              r'\1[{}]\2'.format(env), line)
     return requirements
@@ -46,7 +51,8 @@ setup(
     install_requires=parse_requirements() + parse_requirements('swh'),
-    extras_require={'testing': parse_requirements('test')},
+    extras_require={'testing': (parse_requirements('test') +
+                                parse_requirements('swh', env='testing'))},

The commit mentioned should fix it.
In the current state though, for the build to be green again, that'd need another swh-storage tag (and publish to pypi though).

ardumont added a comment.EditedNov 21 2018, 10:18 AM

In the current state though, for the build to be green again, that'd need another swh-storage tag (and publish to pypi though).

Indeed (after some jenkins massaging, which needed some fix in the publish step). It's green again [1]


ardumont closed this task as Resolved.Nov 21 2018, 10:19 AM