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/ ...
tests/unit/nupic/ ......
***Skipping a bunch of similar lines***
tests/unit/nupic/support/ ......
tests/unit/nupic/support/ ...............
tests/unit/nupic/support/consoleprinter_test/ .

================================================== pytest-warning summary ==================================================
WC1 /Users/kateellis1/Desktop/Suraj/HTM/nupic/tests/unit/nupic/engine/ 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/ 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/ 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/ -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/ -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/ <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/ xfail

tests/unit/nupic/docs/ <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/ xfail

tests/unit/nupic/algorithms/ <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/ SKIPPED

tests/unit/nupic/algorithms/ <- ../../../../anaconda/envs/python2env/lib/python2.7/site-packages/unittest2/ 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