<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<blockquote type="cite"><br>
Is there a reason py.test can't find the flask module in the
pyvenv created virtual environment?
</blockquote>
<br>
Are you sure you are using py.test from your virtualenv and not from
the system? Run `py.test --version` to help with this:<br>
<blockquote type="cite"><tt>(foo)rsyring@loftex:~$ py.test --version</tt><tt><br>
</tt><tt>This is pytest version 2.7.1, imported from
/home/rsyring/.virtualenvs/foo/local/lib/python2.7/site-packages/pytest.pyc</tt><tt><br>
</tt><tt>setuptools registered plugins:</tt><tt><br>
</tt><tt> pytest-cov-1.8.1 at
/home/rsyring/.virtualenvs/foo/local/lib/python2.7/site-packages/pytest_cov.pyc</tt><br>
</blockquote>
Also:<br>
<blockquote type="cite"><br>
AssertionError: b'Hello, World!' != 'Hello, World!'
</blockquote>
<br>
Notice the "b" prefix on the first string. You are getting hung up
by the fact that one is a byte-string and the other is a unicode
string. In Python 2 this would have probably "just worked" but in
Python 3 you have to be more careful.<br>
<br>
HTH.<br>
<div class="moz-signature"><br>
<b>Randy Syring</b><br>
<small>Husband | Father | Redeemed Sinner</small><br>
<br>
<i><small>"For what does it profit a man to gain the whole world<br>
and forfeit his soul?" (Mark 8:36 ESV)</small></i>
<br>
<br>
</div>
<div class="moz-cite-prefix">On 07/08/2015 11:33 PM, Paradox wrote:<br>
</div>
<blockquote cite="mid:559DEB85.3080809@pobox.com" type="cite">I am
trying to learn TDD using the tutorial here:
<br>
<br>
<a class="moz-txt-link-freetext" href="https://github.com/mjhea0/flaskr-tdd">https://github.com/mjhea0/flaskr-tdd</a>
<br>
<br>
The only thing I have done differently from the tutorial is to use
pyvenv rather than virtualenv and to use py.test for my test
runner.
<br>
<br>
When I get to the point of running the first test (on returning
the "Hello, World!" page) the second time (after the app.py file
is created and filled) it still fails as follows:
<br>
<br>
app-test.py:1: in <module>
<br>
from app import app
<br>
app.py:1: in <module>
<br>
from flask import Flask
<br>
E ImportError: No module named 'flask'
<br>
<br>
Running the flask app works fine, it starts the development server
and returns the proper page, there seems to be something wrong
with the test file or the test runner.
<br>
<br>
Incidentally when I run the test without py.test it finds the
module but fails with an error in the returned string:
<br>
<br>
AssertionError: b'Hello, World!' != 'Hello, World!'
<br>
<br>
I haven't figured that one out yet either!
<br>
<br>
Is there a reason py.test can't find the flask module in the
pyvenv created virtual environment?
<br>
<br>
thomas
<br>
===============
<br>
Thomas C. Hicks, MD, MPH
<br>
Training Manager
<br>
Gansu Gateway, Lanzhou, Gansu
<br>
<br>
_______________________________________________
<br>
testing-in-python mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
<br>
<br>
</blockquote>
<br>
</body>
</html>