Python nose2 unit tests with circle.yml



Hey all,

I’m trying to run python unit tests with nose2 through circle.yml configuration. However, nose2 is failing to discover tests when running on circle ci, even though it works locally.

All of the python code is contained one directory up from the root of the repo, in a directory called python_directory. So we’d like to specifiy the start directory for nose2.

Here’s my circle.yml file:

    version: 2.7.10
    PYTHONPATH: ${HOME}/repo_name/python_directory

    - easy_install -U setuptools
    - pip install -r python_directory/python_req.txt

    - echo $PYTHONPATH
    - cd python_directory/ && pwd s&& nose2

Here’s the output from echo $PYTHONPATH:


And here’s the output from running the tests. The name of the file that nose2 should find is

ERROR: test_config (nose2.loader.ModuleImportFailure)
ImportError: Failed to import test module: test_config
Traceback (most recent call last):
  File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/nose2/plugins/loader/", line 200, in _find_tests_in_file
    module = util.module_from_name(module_name)
  File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/nose2/", line 80, in module_from_name
ImportError: No module named test_config

Ran 1 tests in 0.001s

FAILED (errors=1) cd python_directory/ && pwd && nose2 returned exit code 1

It looks like it’s running nose2 from the correct directory, yet it still can’t find the test.

Any ideas on what the correct way to set up nose2 unit tests is?

Python unittest discover works over SSH but not from circle.yml

Hi JKane,

I’m running into the same problem myself. Did you manage to resolve it?