pytest-django Questions

13

Solved

I have PyTest setup in vs-code but none of the tests are being found even though running pytest from the command line works fine. (I'm developing a Django app on Win10 using MiniConda and a Python...
Monoplegia asked 27/1, 2019 at 11:4

2

In the pytest documentation it says that you can customize the output message when an assert fails. I want to customize the assert message when testing a REST API method it returns an invalid statu...
Adelric asked 13/6, 2017 at 12:39

4

I would like pytest-django to install a Postgres extension when it creates a test database. I've been mucking with conftest.py to try to get this to work, but I'm stuck. My conftest.py is at the t...
Fuqua asked 30/1, 2017 at 15:55

7

Solved

Is it possible to prevent the execution of "function scoped" fixtures with autouse=True on specific marks only? I have the following fixture set to autouse so that all outgoing requests are automa...
Disposure asked 3/8, 2016 at 15:47

5

Solved

I am building an API using the django REST framework. To test this API I am using pytest and the test client like so: def test_doesnt_find(self, client): resp = client.post(self.url, data={'name...
Buiron asked 6/10, 2016 at 23:6

2

I am new to django unittest and pytest. However, I started to feel that pytest test case is more compact and clearer. Here is my test cases: class OrderEndpointTest(TestCase): def setUp(self)...
Refine asked 15/6, 2017 at 3:27

6

Solved

I am using django to build my website and I have used django-pytest to test my apps but I have got this error Note I am usign python 3.9 ============================================================...
Upholsterer asked 11/6, 2021 at 12:13

10

Solved

Using the (partial) polls app from the Django tutorial as an example, I'm trying to get pytest-django to run. Using the command django-admin startproject mysite2, I've created a project directory ...
Pleading asked 5/1, 2018 at 2:19

3

Solved

I already know that one can implement a class that inherits from SimpleTestCase, and one can test redirection by: SimpleTestCase.assertRedirects(response, expected_url, status_code=302, target_sta...
Sumerlin asked 17/1, 2018 at 4:30

1

I installed pytest-django and selenium in Django as shown below. pip install pytest-django && pip install selenium Then, I created pytest.ini, test_1.py and __init__.py(Empty file) in test...
Trainbearer asked 5/9, 2023 at 2:12

1

I'm trying to improve the test collection speed by including the testpaths option in the pytest.ini file. Inside each App folder I have a tests file where I put my tests, so I'm including it as fol...
Oui asked 23/11, 2021 at 13:49

4

Solved

During invoking pytest from the shell I get the following output, because my test is stored in apps.business.metrics.tools.tests.py, and during import of the module apps/business/metrics/widgets/em...
Millen asked 13/2, 2019 at 1:21

2

Solved

I have a complex Django-Pytest test suite with lots of tests that are running in parallel processes. I'd like to see the exact timepoint at which each test started and ended. How can I get that inf...
Wakerly asked 26/4, 2020 at 7:38

2

Solved

According to the documentation, --reuse-db should be used or addopts = --reuse-db in pytest.ini. I tried both and they don't work. The current tests have to signup and authenticate a new user at th...
Tess asked 27/12, 2022 at 5:17

4

Solved

My pytest unit test keeps returning the error ModuleNotFoundError: No module name billing. Oddly enough the send_invoices method in the billing module is able to be called when I remove the patch ...
Northeastward asked 5/4, 2020 at 14:25

1

When I run my tests, I realised that pytest-cov only shows coverage reports for files that are touched during the automated tests. How can I set it so that it shows coverage for even files that are...
Banjermasin asked 7/4, 2022 at 9:14

2

Solved

I am following the python-django tutorial in Vagrant (Ubuntu 18.04 / Python3.6.6). After running pip3 install pytest-django and configuring pytest.ini file, running pytest returns Command 'pytest'...
Assentation asked 5/11, 2018 at 12:56

4

Solved

This question is directly related to this question, but that one is now outdated it seems. I am trying to test a view without having to access the database. To do that I need to Mock a RelatedMana...
Provisional asked 29/4, 2019 at 16:41

3

How can I use a pytest fixture within a TestCase method? Several answers to similar questions seem to imply that my example should work: import pytest from django.test import TestCase from myapp.m...
Appendectomy asked 25/10, 2020 at 21:24

3

I'm porting a ~2000 method test suite from nose to pytest because django-nose didn't support parallelization well. Swapping out nose for pytest seemed to work pretty well, and after adding python_f...
Bidding asked 17/2, 2017 at 2:8

1

Solved

I have a django project managed with pytest and poetry. I'd like to put my pytest config into the pyproject.toml file, so I added: [tool.pytest] filterwarnings = ["ignore::django.utils.depreca...
Sarchet asked 3/7, 2021 at 12:43

2

Solved

I am running into strange errors I have never seen before running pytest where I am running my tests and nearly all are erroring out due to not being allowed to access the database. This is a new e...
Extort asked 17/5, 2021 at 12:38

2

Solved

I have been trying to track down some bugs in some concurrent code and wanted to write a test that ran a function in parallel. I am using Django with postgres as my database and testing using pytes...
Geometer asked 4/7, 2019 at 2:33

3

I have a receiver that needs to know whether DEBUG set to True in my settings.py. from django.conf import settings ... @receiver(post_save, sender=User) def create_fake_firebaseUID(sender, instanc...
Indetermination asked 8/11, 2016 at 20:42

2

Solved

I'm having a difficult time figuring out what is wrong with my setup. I'm trying to test a login view, and no matter what I try, I keep getting: Database access not allowed, use the "django_db" ma...
Alisaalisan asked 31/5, 2019 at 5:37

© 2022 - 2024 — McMap. All rights reserved.