ckan / datapusher

A standalone web service that pushes data files from a CKAN site resources into its DataStore
GNU Affero General Public License v3.0
77 stars 155 forks source link

nosetests do not use virtualenv and fail with ImportError #57

Closed florianm closed 10 years ago

florianm commented 10 years ago

With datapusher's virtualenv enabled, this virtualenv's nosetests does not use the virtualenv. Naturally it will fail with

======================================================================
ERROR: Failure: ImportError (No module named httpretty)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/mnt/ckan/datapusher/src/datapusher/tests/test_unit.py", line 12, in <module>
    import httpretty
ImportError: No module named httpretty

Pip freeze disagrees - both httpretty and ckanserviceprovider are installed:

APScheduler==2.1.2
Flask==0.9
Flask-Admin==1.0.8
Flask-Login==0.2.11
Jinja2==2.7.3
MarkupSafe==0.23
Pygments==2.0.1
SQLAlchemy==0.7.8
Sphinx==1.2.3
Unidecode==0.04.16
WTForms==2.0.1
Werkzeug==0.9.6
argparse==1.2.1
chardet==2.1.1
ckanserviceprovider==0.0.1
datapusher==1.0
docutils==0.12
httpretty==0.6.2
itsdangerous==0.24
json-table-schema==0.1
lxml==3.4.0
messytables==0.14.1
nose==1.2.1
python-dateutil==1.5
python-magic==0.4.6
python-slugify==0.1.0
requests==2.4.3
six==1.8.0
sphinxcontrib-httpdomain==1.3.0
urllib3==1.7.1
wsgiref==0.1.2
xlrd==0.9.3

python -c "import httpretty" run inside datapusher's src/datapusher and src/datapusher/tests works fine (no importerror), and which nosetests confirms that nosetests is from the datapusher virtualenv.

Could a section on testing be included in the docs, specifying how to run nosetests using the virtualenv?

florianm commented 10 years ago

Tests now passing after deactivating and re-activating the virtualenv:

root@aws-ckan-001:/mnt/ckan/datapusher/r# . bin/activate
(datapusher)root@aws-ckan-001:/mnt/ckan/datapusher/src/datapusher# nosetests