Y
Y
YuriyCherniy2020-09-20 00:51:24
Django
YuriyCherniy, 2020-09-20 00:51:24

Why doesn't an exception occur?

I am writing tests for a Django application:

class FolderViewsTestCase(TestCase):
    @classmethod
    def setUpTestData(cls):
        LinkyUser.objects.create_superuser(
            username='test_user',
            password='0000'
        )

    def setUp(self):
        self.c = Client()

    def test_folder_update_view_status_code_200(self):
        self.c.login(username='test_user', password='0000')
        user_id = self.c.session['_auth_user_id']
        folder = Folder.objects.create(title='test_folder', linky_user_id=user_id)
        response = self.c.get(reverse('folder_update', args=[folder.pk]))
        self.assertEqual(response.status_code, 200)

at this point a string is returned user_id = self.c.session['_auth_user_id'],
the key argument linky_user_idis expecting an integer, getting a string, the code works without errors, why?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question