wiki2 tests on master have import errors #2882

Closed
stevepiercy opened this Issue Dec 24, 2016 · 2 comments

Projects

None yet

3 participants

@stevepiercy
Member

Ref: #2855 (comment)

On the master branch, after running through the wiki2 tutorial from a cookiecutter or scaffold, then running the tests in the Adding Tests step, there are import errors. To save time, one could follow these steps to reproduce:

I did not install the mock package (it was not included in instructions or setup.py), so I had to change the imports.

Here's the traceback.

$VENV/bin/pytest -q

========================================================================== ERRORS ==========================================================================
______________________________________________________ ERROR collecting tutorial/tests/test_initdb.py ______________________________________________________
ImportError while importing test module '/Users/stevepiercy/projects/__pcs/tutorial/tutorial/tests/test_initdb.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tutorial/tests/test_initdb.py:1: in <module>
    import mock
E   ImportError: No module named 'mock'
_____________________________________________________ ERROR collecting tutorial/tests/test_security.py _____________________________________________________
ImportError while importing test module '/Users/stevepiercy/projects/__pcs/tutorial/tutorial/tests/test_security.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tutorial/tests/test_security.py:1: in <module>
    import mock
E   ImportError: No module named 'mock'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 error in 1.01 seconds
@stevepiercy stevepiercy added this to the 1.8 milestone Dec 24, 2016
@mmerickel
Member
mmerickel commented Dec 24, 2016 edited

The issue is that, as @zupo said, python 3 has unittest.mock but python 2 does not and requires a dependency.

There is no good solution here other than to stop using mock. In real projects it's totally fine for people to use it, but we don't want the scaffolds to do weird 2 vs 3 importing tricks - no one is developing an app from a scaffold that must run on both and the scaffold shouldn't get them started in this direction.

Since we are still supporting python 2.7 in the scaffolds the only real option here is to come up with alternative test implementations using dummy objects and stop relying on the mock module.

@zupo
Contributor
zupo commented Dec 25, 2016
@mmerickel mmerickel closed this in fb7a98b Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment