django-testing

    0热度

    1回答

    我第一次使用django单元测试。以下是我的代码的缩小版本。 我的假设是每个TestCase类都会调用一次setUp函数。但是当我运行python manage.py test命令时,每个测试函数都会调用一次setUp函数。 我做错了什么或者我的假设有什么不对吗? class SampleTest(TestCase): """ This class assumes an ar

    1热度

    1回答

    我已经尝试了下面提到的代码,但它并没有为我工作。 class SeleniumTest(LiveServerTestCase): @classmethod def setUpClass(cls): super().setUpClass() cls.driver = PhantomJS() @override_settings(DEBUG=Tr

    0热度

    1回答

    我想测试一个API后调用,它允许文件上传,但我不能得到它的工作,我总是收到301 with open('video.mp4') as f: data = {'file': f} response = self.client.post('/api/upload_file', data, format='multipart') 返回的响应是301 HttpResponsePer

    1热度

    1回答

    我试图测试我的注册网址。当我做到以下时,它给了我一个错误。 tests.py from __future__ import unicode_literals from django.test import TestCase # Create your tests here. class SignUpTest(TestCase): def test_createAccount(sel

    0热度

    2回答

    我开始为我的django应用程序编写测试,我想知道是否有一种测试方法,同时在多个模型中有相同的功能。例如,如果我想测试所有类中出现的__unicode__()方法,而不是为每个模型编写测试,那么是否可以对所有模型进行优化并对其进行一次测试?

    0热度

    1回答

    我想使用客户端传递字典到函数。它看起来像: response = self.client.post( '/upload_image/', {'image': image, 'tags': ['orion', ]}) 在我看来,它的发布数据,我有: print(request.POST) image = request.POST['image'] tags = reguest.PO

    1热度

    1回答

    过去几周我一直在学习django,我尝试使用参数化fixture和测试函数,从我的理解我可以简单地一次运行多个测试。通过参数化测试,我试图测试所有模型中的函数。我阅读了文档,但不幸的是,只要我尝试过,我收到以下错误消息Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fi

    1热度

    1回答

    我已经尝试了简单的测试,并得到了在控制台此错误消息: AIL: test_get (navbar.test.ContextManagerTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/media/

    0热度

    2回答

    这里是我的看法(简体): @login_required(login_url='/try_again') def change_bar(request): foo_id = request.POST['fid'] bar_id = request.POST['bid'] foo = models.Foo.objects.get(id=foo_id) if

    3热度

    1回答

    我正在编写一个具有自定义模型字段的应用程序。我想使用仅在测试中使用的模型来测试该字段,但我正在努力使模型在测试中工作。 我的一些应用程序的结构是这样的: myapp/ fields.py models.py tests/ fields/ models.py tests.py settings.py test_models.