'Responses can be inspected for content, including counting repeated substrings'

def test_contains(self):

    response = self.client.get('/no_template_view/')
    self.assertNotContains(response, 'never')
    self.assertContains(response, 'never', 0)
    self.assertContains(response, 'once')
    self.assertContains(response, 'once', 1)
    self.assertContains(response, 'twice')
    self.assertContains(response, 'twice', 2)
    try:
        self.assertContains(response, 'text', status_code=999)
    except AssertionError as e:
        self.assertIn("Couldn't    retrieve    content:    Response    code    was    200    (expected    999)", str(e))
    try:
        self.assertContains(response, 'text', status_code=999, msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Couldn't    retrieve    content:    Response    code    was    200    (expected    999)", str(e))
    try:
        self.assertNotContains(response, 'text', status_code=999)
    except AssertionError as e:
        self.assertIn("Couldn't    retrieve    content:    Response    code    was    200    (expected    999)", str(e))
    try:
        self.assertNotContains(response, 'text', status_code=999, msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Couldn't    retrieve    content:    Response    code    was    200    (expected    999)", str(e))
    try:
        self.assertNotContains(response, 'once')
    except AssertionError as e:
        self.assertIn("Response    should    not    contain    'once'", str(e))
    try:
        self.assertNotContains(response, 'once', msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Response    should    not    contain    'once'", str(e))
    try:
        self.assertContains(response, 'never', 1)
    except AssertionError as e:
        self.assertIn("Found    0    instances    of    'never'    in    response    (expected    1)", str(e))
    try:
        self.assertContains(response, 'never', 1, msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Found    0    instances    of    'never'    in    response    (expected    1)", str(e))
    try:
        self.assertContains(response, 'once', 0)
    except AssertionError as e:
        self.assertIn("Found    1    instances    of    'once'    in    response    (expected    0)", str(e))
    try:
        self.assertContains(response, 'once', 0, msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Found    1    instances    of    'once'    in    response    (expected    0)", str(e))
    try:
        self.assertContains(response, 'once', 2)
    except AssertionError as e:
        self.assertIn("Found    1    instances    of    'once'    in    response    (expected    2)", str(e))
    try:
        self.assertContains(response, 'once', 2, msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Found    1    instances    of    'once'    in    response    (expected    2)", str(e))
    try:
        self.assertContains(response, 'twice', 1)
    except AssertionError as e:
        self.assertIn("Found    2    instances    of    'twice'    in    response    (expected    1)", str(e))
    try:
        self.assertContains(response, 'twice', 1, msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Found    2    instances    of    'twice'    in    response    (expected    1)", str(e))
    try:
        self.assertContains(response, 'thrice')
    except AssertionError as e:
        self.assertIn("Couldn't    find    'thrice'    in    response", str(e))
    try:
        self.assertContains(response, 'thrice', msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Couldn't    find    'thrice'    in    response", str(e))
    try:
        self.assertContains(response, 'thrice', 3)
    except AssertionError as e:
        self.assertIn("Found    0    instances    of    'thrice'    in    response    (expected    3)", str(e))
    try:
        self.assertContains(response, 'thrice', 3, msg_prefix='abc')
    except AssertionError as e:
        self.assertIn("abc:    Found    0    instances    of    'thrice'    in    response    (expected    3)", str(e))
