Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNitin Chauhan
Courses Plus Student 277 PointsSyntax error: python -m unittest test.py
Hi,
I tried testing the same code Kenny wrote in the video on my laptop. But the shell says syntax error and highlights unittest. I am not sure what the problem is. It was showing the same error when I wrote a doctest and tried to test it. Kindly help.
1 Answer
Nate Paradis
6,784 PointsIt looks like you are trying to run python -m unittest test.py
in the Python shell. I am guessing your output looks like this?
Nateβs-MacBook-Pro:~ nate.paradis$ python3
Python 3.7.5 (default, Nov 1 2019, 02:16:32)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> python -m unittest test.py
File "<stdin>", line 1
python -m unittest test.py
^
SyntaxError: invalid syntax
This command needs to be run from like a terminal window. If you are stuck in the Python shell you can quit using exit()
. Good luck.