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 trialDan Badertscher
5,327 PointsassertTrue Challenge
' We haven't used assertTrue yet but I'm sure you can handle this. assertTrue checks that a value is truthy. Complete the first test using assertTrue. Provide your own good palindrome or use "tacocat". '
My code:
import unittest
from string_fun import is_palindrome
class PalindromeTestCase(unittest.TestCase):
def test_good_palindrome(self):
palin1 = self.is_palindrome()
palin2 = self.is_palindrome()
self.assertTrue(palin1 = palin2 )
pass
def test_bad_palindrome(self):
pass
Can someone point me in the right direction?
5 Answers
Ken Alger
Treehouse TeacherDan;
Let's have a look...
Task 1
We haven't used
assertTrue
yet but I'm sure you can handle this.assertTrue
checks that a value is truthy. Complete the first test usingassertTrue
. Provide your own good palindrome or use "tacocat
".
def test_good_palindrome(self):
pass
If you look in the other tab, string_fun.py
, you see that we have a function to use, is_palindrome
. We are asked to use the assertTrue
method. If we take a look at the docs we see that it takes an expression and returns a Boolean value, and several examples of it's implementation.
Our challenge then, is to take the argument passed into test_good_palindrome()
and check if is_palindrome()
return a True value based on a palindrome of our choice. Mr. Love provided one for us, tacocat
.
Without trying to explicitly spell out the challenge answer, try it again and see if those steps point you to a solution.
Happy coding,
Ken
Annie Scott
27,613 Pointsclass PalindromeTestCase(unittest.TestCase): def test_good_palindrome(self): self.assertTrue(is_palindrome('tacocat'))
MUZ140348 Sympathy Makururu
10,209 PointsDO NOT BOTHER I WORKED IT OUT ALONE: 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
Annie Scott
27,613 Pointstask 1
class PalindromeTestCase(unittest.TestCase): def test_good_palindrome(self): self.assertTrue(is_palindrome('tacocat'))
MUZ140348 Sympathy Makururu
10,209 PointsHi Annie: I am facing Challenges with the Second Task:
Any Help.
import unittest
from string_fun import is_palindrome
class PalindromeTestCase(unittest.TestCase): def test_bad_palindrome(self): self.assertFalse(is_palindrome('tacocat'))
pierreilyamukuru
9,831 PointsHi Sympathy, You are missing not before tacocat, Please write self.assertFalse(is_palindrome('not tacocat')) I think this will help
Dan Badertscher
5,327 PointsDan Badertscher
5,327 PointsThank you Ken! The docs link helped out.
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherDan;
I have found that checking the docs is often a great place to start. Python's docs are generally pretty good. Some languages have official docs that are not quite so user friendly.
Happy coding,
Ken
Brendan Thompson
2,939 PointsBrendan Thompson
2,939 PointsNone of that really helps me out. Could you possibly help me out on this. I had what he had for the most part.
MUZ140348 Sympathy Makururu
10,209 PointsMUZ140348 Sympathy Makururu
10,209 PointsCHALLENGE TASK 2: FAILING TO PASS. ANY HELP. import unittest
from string_fun import is_palindrome
class PalindromeTestCase(unittest.TestCase): def test_good_palindrome(self): self.assertTrue(is_palindrome('tacocat'))