Python import fails on travisCI but not locally

I am trying to integrate TravisCI into my workflow and realized that I have some dependencies due to my old directory structure (not having standalone, virtualenv-able git repos).

When I try to run nosetestslocally, it just runs the tests; when TravisCI tries to launch them, it fails with an error import. In particular, I have one of the lines in my test script:

from myproject import something

My directory structure inside my git repo myprojectlooks something like this:

.travis.yml
requirements.txt
something.py
tests/
    test_something.py
  • I tried to get this locally (because then I would understand the TravisCI problem, maybe), but I can't do it.
  • I tried working with regular python and used virtualenv, which added noseto it requirements.txt, and the tests always passed locally.

I feel that I still have not understood the absolute import-relative import, and I can’t say whether it will play here, or if I just do something obvious and dumb in my project.

Desired result: find out why TravisCI fails, and fix my repo accordingly so that I can accomplish and build things correctly, both locally and in TravisCI. If this requires more radical changes, such as “you must have setup.pyone that makes blah-blah in the environment” or similar, please let me know. I am new to this aspect of Python and find the current documentation inconsistent.

FYI, , --exe .

+4
1

, , , -:

1

, PYTHONPATH=$PYTHONPATH:$(pwd) .travis.yml:

before_install:
  - "pip install -U pip"
  - "export PYTHONPATH=$PYTHONPATH:$(pwd)"

2

setup.py, , , :

from setuptools import setup, find_packages

setup(name='MyPythonProject',
      version='0.0.1',
      description='What it does',
      author='',
      author_email='',
      url='',
      packages=find_packages(),
     )

.travis.yml

before_install:
  - "pip install -U pip"
  - "python setup.py install"

3:

(, ), :

.travis.yml
requirements.txt
app
|_ tests
|   |_ test_application.py
|_ application.py

:

script:
    - "nosetests --with-coverage --cover-package app"
0

All Articles