# Testing the code

**URL:** <https://forum.djangoproject.com/t/testing-the-code/6277>\
**Category:** Using Django\
**Created:** [January 23, 2021, 10:50pm UTC](https://forum.djangoproject.com/t/testing-the-code/6277 "2021-01-23T22:50:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user1234](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/user1234/32/3251_2.png) [@user1234](https://forum.djangoproject.com/u/user1234)\
**Post date:** [January 23, 2021, 10:50pm UTC](https://forum.djangoproject.com/t/testing-the-code/6277/1 "2021-01-23T22:50:10Z")

</div>

I have a flatpage in my website. I created it by writing this:  
urlpatterns = [

```
path('admin/', admin.site.urls),
path('facts/', include('django.contrib.flatpages.urls')),]

```

After that in admin page I created a page about-me, so the whole url for that page is ‘localhost/facts/about-me/’

I tried to write test for this page:  
class StaticURLTests(TestCase):  
def setUp(self):  
self.guest\_client = Client()

```
def test_about_author(self):
    response = self.guest_client.get('/facts/about-me/')
    self.assertEqual(response.status_code, 200)

```

But I get the following error:  
self.assertEqual(response.status\_code, 200)  
AssertionError: 404 != 200  
FAILED (failures=1)  
Destroying test database for alias ‘default’…

Can’t figure out why. Maybe smb was facing the same problem

---

<div class="post-metadata">

**Author:** ![marcorichetta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marcorichetta/32/26473_2.png) [@marcorichetta](https://forum.djangoproject.com/u/marcorichetta)\
**Post date:** [January 24, 2021, 9:54pm UTC](https://forum.djangoproject.com/t/testing-the-code/6277/2 "2021-01-24T21:54:28Z")

</div>

Hi!

HTTP 404 status code means a [Not Found](https://en.wikipedia.org/wiki/HTTP_404) error.

For testing Django creates a test database by default so your `about-me` page doesn’t exist in there.

The `setUp` stage is useful for creating test data, in this case a [FlatPage](https://docs.djangoproject.com/en/3.1/ref/contrib/flatpages/#via-the-python-api), and then you can query it like you already did.
