TypeError: Type str doesn't support the buffer API in assertTrue in testcase
Question: I am using python 3.4 and Django 1.8.2

I am performing some test cases about of the Artist object using some asserts:

I want that the page return me in my test of `/artist/<id>` (stored in the res
variable) and return me the 200 status code which is the O.K. in http protocol

Also, I want that check in the content the word with the name of artist

    
    
    from django.test import TestCase
    from .models import Artists
    
    class TestArtist(TestCase):
        def setUp(self):
            self.artist = Artists.objects.create(first_name = 'Ricky', 
            last_name ='Martin')
    
        def test_existe_vista(self):
            #print (self.client.get('/artists/%d' % self.artist.id))
            res = self.client.get('/artists/%d' % self.artist.id)
            self.assertEqual(res.status_code, 200)
            self.assertTrue('Ricky' in res.content)
    

The output is:

    
    
    (venv)➜  myproject  ./manage.py test artists
    Creating test database for alias 'default'...
    /home/bgarcial/.virtualenvs/venv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py:57: RuntimeWarning: SQLite received a naive datetime (2015-07-08 05:09:23.051431) while time zone support is active.
      RuntimeWarning)
    
    E
    ======================================================================
    ERROR: test_existe_vista (artists.tests.TestArtist)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/bgarcial/workspace/Project/myprojec/artists/tests.py", line 43, in test_existe_vista
        self.assertTrue('Ricky' in res.content)
    TypeError: Type str doesn't support the buffer API
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.286s
    
    FAILED (errors=1)
    Destroying test database for alias 'default'...
    /home/bgarcial/.virtualenvs/venv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py:57: RuntimeWarning: SQLite received a naive datetime (2015-07-08 05:09:23.236391) while time zone support is active.
      RuntimeWarning)
    
    (venv)➜  project  
    

What mean `TypeError: Type str doesn't support the buffer API` in my
assertTrue assertion?

About of the subject I also want comment that when I execute the first test or
the first line (before to asserts) in which I print the artist object, this
object is printed of this way:

How to can I print the object readable for humans?

The **str** method does not works for me here inside the test case like in my
admin.py files

With respect to the SQLite Warning I guess that I should explore :) Thanks


Answer: Going throught the same thing here. Try doing `self.assertTrue('Ricky' in
str(res.content))`

