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 trial

Python Python Testing Be Assertive assertTrue and assertFalse

python testing

dont know what is wrong with my code .

tests.py
import unittest

from string_fun import is_palindrome


class PalindromeTestCase(unittest.TestCase):
    def test_good_palindrome(self):
        pass

    def test_bad_palindrome(self):
        pass

    class PalindromeTestCase(unittest.TestCase):
        def test_good_palindrome(self):
            self.assertTrue(is_palindrome('tacocat'))
string_fun.py
import unittest

from string_fun import is_palindrome

class PalindromeTestCase(unittest.TestCase):
    def test_good_palindrome(self):
        self.assertTrue(is_palindrome('tacocat'))
        def test_bad_palindrome(self):
            self.assertFalse(is_palindrome())
            pass

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Masline,

In your tests.py file, you are implementing the stub method already provided. As such, instead of dropping a whole new class into the existing class, you just need to replace the word pass in the existing test_good_palindrome(self): method with the implementation you provided in your test_good_palindrome(self): method (i.e., self.assertTrue(is_palindrome('tacocat'))).

You shouldn't have done anything to string_fun.py since you are just testing that this file works, not changing its behaviour.

Hope that clears things up.

Cheers

Alex