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

Great! Now let's use the reverse of assertTrue which is assertFalse. Fill out test_bad_palindrome with the assertFalse assertion, is_palindrome, and a bad palindrome.

someone help me please what am i missing

import unittest

from string_fun import is_palindrome

class PalindromeTestCase(unittest.TestCase):
    def test_good_palindrome(self):
def is_palindrome(yarn):
    """Return whether or not a string is a palindrome.

    A palindrome is a word/phrase that's the same in
    both directions.
    return yarn == yarn[::-1]

4 Answers

No worries!

class PalindromeTestCase(unittest.TestCase):
    def test_good_palindrome(self):
        # assertTrue will check if the passed parameter returns True
        # In order to make it true, we have to pass a string that is a palindrome

    def test_bad_palindrome(self):
        # assertFalse will check if the passed parameter returns False
        # In order to make it true, we have to pass a string that is not a palindrome

All the best with your learning! You got this!


When the coding challenge started, it provided some code that looked like this:

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

    def test_bad_palindrome(self):

You have filled out the first method perfectly! The second method is what you still need to fill out. In the code you provided, you have the second method deleted. You should have them both.

In this second method, it looks like you'll be using assertFalse() instead of assertTrue(). The only difference between them is that assertFalse looks for the passed variable to be false instead of true, so you'll have to pass something other than "tacocat" to make it work!

sorry i keep failing can you share your full code

Thank you very much