Conda-forge.github.io: Test import succeeds and in the next test section it fails

Created on 2 Mar 2017  路  4Comments  路  Source: conda-forge/conda-forge.github.io

I am getting an error that I cannot explain at all. In the mshr-feedstock this is the testing section:

test:
  source_files:
    - test
  imports:
    - mshr

The import test is successful (see this build):

===== testing package: mshr-2016.2.0-py27_0 =====
import: 'mshr'
===== mshr-2016.2.0-py27_0 OK =====

but right after it executes run_test.py which contains:

$PYTHON "test/test-meshes.py"
$PYTHON "test/test-mesh-generation.py"

This is the build log:

+/bin/bash -x -e /Users/travis/miniconda3/conda-bld/mshr_1487759334265/test_tmp/run_test.sh
+/Users/travis/miniconda3/conda-bld/mshr_1487759334265/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/bin/python test/test-meshes.py
Traceback (most recent call last):
  File "test/test-meshes.py", line 2, in <module>
    import mshr
ImportError: No module named mshr
/Users/travis/miniconda3/conda-bld/mshr_1487759334265/test_tmp/run_test.sh: line 1:  4042 Abort trap: 6           $PYTHON "test/test-meshes.py"
TESTS FAILED: mshr-2016.2.0-py27_0

and test/test-meshes.py is only this:

from dolfin import *
import mshr

# Unit sphere mesh
m = mshr.UnitSphereMesh(4)
m = mshr.UnitSphereMesh(10) 

Whenever I run the build in the conda-forge anvil Docker image and leave out run_test.sh the build is successful and I can execute the tests without problems.

I think the $PYTHON variable is wrongly defined when running run_test.sh.

This seems to be a strange issue, not sure whether it's a bug of conda, conda-forge, or just me...

Most helpful comment

This is closed, but for the archives sake:

the goal of the test part of conda-build is to see if the package works in an environment similar to what and end user will have. So the environment variables set during building are NOT set, as they won't be set in an end user environment.

So you absolutely want to use "python" to run a python test script, for instance, as you want to run your tests with what a user would get by calling "python"

-CHB

All 4 comments

Generally I haven't had a good experience using any environment variable in the test section except PREFIX. Would recommend changing that to just python. Though feel free to raise an issue with conda-build.

Thanks a lot @jakirkham, changing to python indeed fixed it. I also opened https://github.com/conda/conda-build/issues/1785.

Great! Glad that worked for you.

Let's see what happens with that issue.

This is closed, but for the archives sake:

the goal of the test part of conda-build is to see if the package works in an environment similar to what and end user will have. So the environment variables set during building are NOT set, as they won't be set in an end user environment.

So you absolutely want to use "python" to run a python test script, for instance, as you want to run your tests with what a user would get by calling "python"

-CHB

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artPlusPlus picture artPlusPlus  路  5Comments

peterjc picture peterjc  路  4Comments

prachi237 picture prachi237  路  5Comments

h-vetinari picture h-vetinari  路  4Comments

jakirkham picture jakirkham  路  3Comments