Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,862 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