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] Was this me? ImportError: Failed to import test module: tests
for some reason, i seem to be getting an error that LOOKS like it was treehouse. (it probably isn't.)
the error:
treehouse:~/workspace/dice$ python -m unittest tests.py
E
======================================================================
ERROR: tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests
Traceback (most recent call last):
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/unittest/loader.py", line 153, in loadTestsFromName
module = __import__(module_name)
ImportError: No module named 'tests'
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
treehouse:~/workspace/dice$
the code:
import unittest
import dice
class DieTest(unittest.TestCase):
def setUp(self):
self.d6 = dice.Die(6)
self.d8 = dice.Die(8)
def test_creation(self):
self.assertEqual(self.d6.sides, 6)
self.assertIn(self.d6.value, range(1, 7))
1 Answer
James N
17,864 Pointsnvm... it was me. i typed TESTS.py, instead of TEST.py. facepalm
Gianmarco Mazzoran
22,076 PointsSorry I was testing with you answer opened in another page and see now! Glad that you resolve your issue!
Valeriya Romashchenko
11,841 PointsI've made the same mistake and found the answer here. Thank you!
Gianmarco Mazzoran
22,076 PointsGianmarco Mazzoran
22,076 PointsHi,
maybe it's only an error here in the answer. Are you sure that your file is named "tests.py"?