LoginSignup
0
0

More than 5 years have passed since last update.

[django]ブラウザテストをしたい

Posted at

django.test.Client を使う。


from django.test import Client, TestCase

class HogeTestCase(TestCase):

    def setUp(self):

        self.user = User.objects.create_user('HogeTaro', 'taro@hoge.com', 'password')

        self.client = Client()

        self.client.login(username='HogeTaro', password='password')

    def test_foo(self):

        data = {
            'name': 'FooJiro',
            'email': 'jiro@foo.com',
        }

        response = self.client.post('[URL_Path]', data)

        self.assertEqual(200, response.status_code)

参考URL
- https://docs.djangoproject.com/ja/2.1/topics/testing/tools/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0