Nupic Unit Test Failing

Hi. I’ve recently installed Nupic using “pip install nupic --user”, and I cloned the github repo. But when I run the unit tests, I get failures. Any suggestions?
My specs:
macOS 10.12
pip 19.1.1
python 2.7
python 3.5 (which is why I specify python2 in the command below)

My console looks like:

Katherines-MBP:nupic kateellis1$ python2 -m py.test tests/unit

**=================================================== test session starts ====================================================**
platform darwin -- Python 2.7.16, pytest-3.0.7, py-1.8.0, pluggy-0.4.0
rootdir: /Users/kateellis1/Desktop/Suraj/HTM/nupic, inifile:
plugins: xdist-1.16.0, cov-2.5.0
**collected 738 items** 

tests/unit/nupic/serializable_test.py ...
tests/unit/nupic/utils_test.py ......
tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py ...ss..
***Skipping a bunch of similar lines***
tests/unit/nupic/support/group_by_test.py ......
tests/unit/nupic/support/object_json_test.py ...............
tests/unit/nupic/support/consoleprinter_test/consoleprinter_test.py .

================================================== pytest-warning summary ==================================================
WC1 /Users/kateellis1/Desktop/Suraj/HTM/nupic/tests/unit/nupic/engine/network_test.py cannot collect test class 'TestNode' because it has a __init__ constructor
***Skipping a bunch of similar lines***
WC1 /Users/kateellis1/Desktop/Suraj/HTM/nupic/tests/unit/nupic/support/decorators_test.py cannot collect test class 'TestChildException' because it has a __init__ constructor
**========================== 713 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 265.82 seconds ==========================**

I also tried the following:

Katherines-MBP:nupic kateellis1$ python2 -m scripts/run_nupic_tests.py tests/unit

And I got the output:
/usr/local/opt/python@2/bin/python2.7: Import by filename is not supported.

Thanks for any help.

Hi @Suraj. Try this from the root repo directory:

python ./scripts/run_nupic_tests.py -u --failfast

Hi @rhyolight,
When I ran your command, the test session said that it was running Python 3.5.6, which is odd since python -V gives me Python 2.7.16. So I tried specifying python2, as in python2 ./scripts/run_nupic_tests.py -u --failfast, and again it said it was running Python 3.5.6, which I don’t understand. So finally I created a new conda environment for Python 2.7. This time, when I ran your command, it worked and spit out hundreds of lines of test results, but it still says **==== 713 passed, 17 skipped, 8 xfailed, 5 pytest-warnings in 534.95 seconds ====**

Here are some of the skips and xfails:

tests/unit/nupic/docs/examples_test.py::ExamplesTest::testFiveStepConfidencesOpfVsNetwork <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py xfail

tests/unit/nupic/docs/examples_test.py::ExamplesTest::testFiveStepPredictionsOpfVsNetwork <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py xfail

tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py::ArtificialAnomalyTest::testCaseMissingBunchesOfSpikes <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py SKIPPED

tests/unit/nupic/algorithms/anomaly_likelihood_jeff_test.py::ArtificialAnomalyTest::testCaseMissingSpike <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/case.py SKIPPED

1 Like

Ok, I replicated this on conda and got the same test results. Then I realized you were citing xfail, which is “expected failure”. So nothing wrong here. :stuck_out_tongue:

Oh good! Thanks for looking into that!

What is the ideal method for avoiding Python version problems when using NUPIC? Is virtualenv preferable over conda?

Also, regarding my previous errors (before I created the new environment), do you have any idea why the tests were invoking Python 3 even though I was using Python 2 on the command line?

Thanks again.

I’ve used both, and it’s just a personal preference.

Running python 2 & 3 can be a bit tricky depending on your OS. The Mac python environment is particularly hairy. It probably had something to do with python 3 being invoked as the default python from within the test runner.

1 Like