I have a python file called AllTests.py which looks like the following:
from SomeWonderfulTest import SomeWonderfulTestCase
theTestSuite = unittest.TestSuite()
if __name__ == "__main__":
I can run this at the command line as follows:
python -m unittest AllTests
However, I would like to use the Spyder IDE to debug some issues. I know to specify command line options in Spyder, I can go to Run->General Setting->Command line options. However, when I try to put "-m unittest" into these options, I get an error saying "option -m not recognized." It appears it's trying to send the argument to the AllTests.py file instead of to python.
How do I setup Spyder to debug these unittests?
So I am fairly new to Spyder, as we are using Visual Studio to do our dev, however the principals appear similar.
So, how we have things working is as follows:
IDE is the interface you use to do your development. (Spyder in your case, or VS in mine.)
Anaconda is (my) the Python Environment which reads and executes the python scripts you write. This gives you the interpreter window, etc. The IDE uses the Python Environment to run your scripts.
You can run your tests in a few different ways.
You have created a wrapper class/method called AllTests.py which is a python script.
This AllTests.py script can be ran in the console directly as you have outlined in your question.
You could also run your AllTests.py script as you would any other script, as outlined by carlos.
You can also install an addon into your IDE (Spyder / VS / etc) which interprets all UnitTest classes, and displays them in a visual way, instead of using the command line. A Test Explorer (as it is called in VS), or alternative addon would look through your code, and find all your tests, group them together in various different ways, allow you to execute them by name / group / etc, and give you further information on the tests and their outputs. (Execution time, pass/fail outputs, etc,)
One I found for Spyder is here: https://pypi.python.org/pypi/spyder-unittest
Not sure if it is any good, as I've not used it. Someone else here may be able to comment on it's ability/performance.
Below is a screenshot of the Visual Studio Test Explorer:
Depending on your requirements and development practices, this testing addon may be a better option for you.
I hope this is of some help.