DamnWidget / anaconda

Anaconda turns your Sublime Text 3 in a full featured Python development IDE including autocompletion, code linting, IDE features, autopep8 formating, McCabe complexity checker Vagrant and Docker support for Sublime Text 3 using Jedi, PyFlakes, pep8, MyPy, PyLint, pep257 and McCabe that will never freeze your Sublime Text 3
http://damnwidget.github.io/anaconda/
GNU General Public License v3.0
2.22k stars 259 forks source link

"Run test under cursor" fails with python error #238

Closed chetan51 closed 9 years ago

chetan51 commented 10 years ago

When I use the "Run test under cursor" feature, I see the following error in my Sublime Text console:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
    return self.run(edit)
  File "/Users/Chetan/Library/Application Support/Sublime Text 3/Packages/Anaconda/commands/test_runner.py", line 140, in run
    command = self._prepare_command()
  File "/Users/Chetan/Library/Application Support/Sublime Text 3/Packages/Anaconda/commands/test_runner.py", line 26, in wrapper
    result = func(self)
  File "/Users/Chetan/Library/Application Support/Sublime Text 3/Packages/Anaconda/commands/test_runner.py", line 176, in _prepare_command
    return ' '.join(command)
TypeError: sequence item 1: expected str instance, NoneType found
DamnWidget commented 10 years ago

What do you have under the cursor when you use the feature?

chetan51 commented 10 years ago

I tried putting the cursor on the following lines:

https://github.com/numenta/nupic/blob/master/tests/unit/py2/nupic/research/temporal_memory_test.py#L41 https://github.com/numenta/nupic/blob/master/tests/unit/py2/nupic/research/temporal_memory_test.py#L47

DamnWidget commented 10 years ago

Well, as you can see here, this project seems to be really complex, make sure that you can run the tests following their instructions there and if you are able to pass the tests then you should configure the anaconda's test runner in order to run the tests in that project cos they aren't going to work out of the box.

Take a look at the anaconda's test runner documentation for more information

Installing nupic in a virtual environment and following the procedure below I managed to run the whole test suite (I am not familiar with pytest so I am not sure how the configuration to make test under the cursor be fired will be, but I am pretty sure that it can be configured)

I cloned numpic in my /tmp directory.

mkvirtualenv borrame
cd /tmp/numpic
pip install -r external/common/requirements.txt
python setup.py build
python setup.py develop 

Then I saved a project file for numpic and configured it as:

"settings":
    {
        "python_interpreter": "/home/damnwidget/.virtualenvs/borrame/bin/python",
        "test_command": "python /tmp/nupic/scripts/run_tests.py -u",
        "test_before_command": "export NUPIC=/tmp/nupic",
        "test_virtualenv": "~/.virtualenvs/borrame"
    }

Then when I run, Run full project test suite It just get tested:

========================================================= test session starts ==========================================================
platform linux2 -- Python 2.7.6 -- pytest-2.4.2 -- /home/damnwidget/.virtualenvs/borrame/bin/python
plugins: xdist, cov
collected 815 items / 2 skipped 

tests/external/py2/asteval_test.py:32: TestCase.testImportAndVersions PASSED
tests/external/py2/testfixture_test.py:48: TestPytest.testSetUpModuleCalled PASSED
tests/unit/py2/nupic/utils_test.py:37: UtilsTest.testMovingAverage PASSED
tests/unit/py2/nupic/utils_test.py:76: UtilsTest.testMovingAverageInstance PASSED
tests/unit/py2/nupic/algorithms/anomaly_likelihood_jeff_test.py:166: ArtificialAnomalyTest.testCaseContinuousBunchesOfSpikes PASSED
tests/unit/py2/nupic/algorithms/anomaly_likelihood_jeff_test.py:250: ArtificialAnomalyTest.testCaseIncreasedAnomalyScore PASSED
tests/unit/py2/nupic/algorithms/anomaly_likelihood_jeff_test.py:193: ArtificialAnomalyTest.testCaseIncreasedSpikeFrequency PASSED
tests/unit/py2/nupic/algorithms/anomaly_likelihood_jeff_test.py <- ../../home/damnwidget/.virtualenvs/borrame/local/lib/python2.7/site-packages/unittest2/case.py:58: ArtificialAnomalyTest.testCaseMissingBunchesOfSpikes SKIPPED
...
tests/unit/py2/regions/regions_spec_test.py:75: KNNAnomalyClassifierRegionTest.testValidOutputSpec PASSED
tests/unit/py2/regions/regions_spec_test.py:110: KNNAnomalyClassifierRegionTest.testValidParameterSpec PASSED
tests/unit/py2/regions/regions_spec_test.py:163: KNNAnomalyClassifierRegionTest.testValidSpec PASSED

=============================================== 800 passed, 17 skipped in 115.47 seconds ===============================================

note: the output has been shortened for displaying purposes

chetan51 commented 10 years ago

Thanks for putting in the effort! I was already able to run all the tests in the project, but I wasn't able to run an individual test using anaconda. Were you able to use the "Run test under cursor" on an individual unit test in the project?

DamnWidget commented 10 years ago

Nope, I have no idea how to run individual tests using pytest, I just managed to run tests on current file using "test_command": "python -m unittest",

chetan51 commented 10 years ago

What does anaconda's feature "Run test under cursor" do in order to run an individual test? I am trying to make that work with the nupic project.

DamnWidget commented 10 years ago

Hi @chetan51

I am going to sleep now (almost 03:00 AM here in Dublin) but you can take a look at here and here

chetan51 commented 10 years ago

Thanks. I'm curious, if you run the same unit test using the "Run test under cursor feature" that I pointed out in my original description, in your cloned nupic repo, what do you see? Do you see the error I mentioned?

DamnWidget commented 10 years ago

Yes.

DamnWidget commented 10 years ago

I'll take a look on that this weekend but fixes wouldn't be available until 1.3.5

chetan51 commented 10 years ago

Thanks so much!

DamnWidget commented 9 years ago

This error has been fixed in branch fix238, waiting for release v1.3.6

chetan51 commented 9 years ago

Thanks!