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 trialJames N
17,864 Points[RESOLVED] REALLY LARGE TRACEBACK! NameError: name 'TestCase' is not defined
The error:
treehouse:~/workspace/rps$ python -m unittest test.py
Traceback (most recent call last):
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/runpy.
py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/runpy.
py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unitte
st/__main__.py", line 18, in <module>
main(module=None)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unitte
st/main.py", line 93, in __init__
self.parseArgs(argv)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unitte
st/main.py", line 140, in parseArgs
self.createTests()
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unitte
st/main.py", line 147, in createTests
self.module)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unitte
st/loader.py", line 219, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name
in names]
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unitte
st/loader.py", line 219, in <listcomp>
suites = [self.loadTestsFromName(name, module) for name
in names]
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unitte
st/loader.py", line 153, in loadTestsFromName
module = __import__(module_name)
File "/home/treehouse/workspace/rps/test.py", line 6, in <
module>
class MoveTests(unittest, TestCase):
NameError: name 'TestCase' is not defined
treehouse:
The code:
import unittest
import moves
class MoveTests(unittest, TestCase):
def test_five_plus_five(self):
assert 5 + 5 == 10
def test_one_plus_one(self):
assert not 1 + 1 == 3
The question: Why am i getting a traceback with more lines than my code? What did i do wrong? Thanks, james.
2 Answers
James N
17,864 Pointsnever mind! i couldn't see the video very well on my device, i typed a ,
instead of a .
.
Sandy Goreraza
7,391 PointsLooking at your class MoveTests code ,i.e class MoveTests(unittest, TestCase): you placed a comma instead of full stop (.)
your code should read
class MoveTests(unittest.TestCase):
it will run with success.......!