pytest-django Questions

1

Solved

I have been trying to parameterize my tests using @pytest.mark.parametrize, and I have a marketer @pytest.mark.test("1234"), I use the value from the test marker to do post the results to...
Hominid asked 24/8, 2020 at 12:58

1

Solved

First, I tired this: @pytest.mark.django_db @pytest.fixture(scope='session') def created_user(django_db_blocker): with django_db_blocker.unblock(): return CustomUser.objects.create_user("Use...
Crissie asked 3/7, 2020 at 20:56

3

Solved

In the unittest style, I can test that a page uses a particular template by calling assertTemplateUsed. This is useful, for example, when Django inserts values through a template, so that I can't j...
Albertoalberts asked 28/8, 2017 at 20:2

1

Solved

I have made my custom management command called pytest_wrp So when I call python manage.py test This bit of code is called: class Command(test.Command): def handle(self, *args, **options): supe...

1

Solved

I have a large Django application with tons of tests that need SQL query optimizations. I'm using pytest-django to run my tests. I don't want to add assertNumQueries or django-assert-num-queries ...
Harvard asked 24/4, 2020 at 10:8

0

I'm running tests against a model having a ArrayField(CICharField()) field and they return a string instead of a list. I use pytest-django to run the tests. I know that returning a string instead ...
Simasimah asked 24/10, 2019 at 16:4

2

I need to explicitly delete a fixture after it is used. I know that pytest-django by default drops all objects on teardown but in this particular case I need to do it manually. However, although my...
Tarra asked 24/5, 2018 at 10:5

2

I would like to write a unit test for a view on a Django REST Framework application. The test should upload a file using PUT, in essence equivalent to http -a malkarouri PUT http://localhost:800...
Wharfage asked 15/6, 2017 at 12:9

2

Solved

Bottom Line: My Django connections object does not see the table relations of a second database during testing with pytest-django. Overview: I have a problem where my Django connections object se...
Festoon asked 14/4, 2018 at 20:32

1

Solved

Say I'm testing an RSS feed view in a Django app, is this how I should go about it? def test_some_view(...): ... requested_url = reverse("personal_feed", args=[some_profile.auth_token]) resp = ...
Foliage asked 8/6, 2019 at 23:27

2

Solved

I am defining a pytest fixture that to overrides the django_db_setup fixture. The change I have sets up additional teardown for safety, as there are integration tests that use this fixture which m...
Occupier asked 16/5, 2019 at 8:1

2

Solved

I need to add fixtures to the live_server fixture provided by pytest-django specifically an overwritten django_db_setup. That being said I understand it is not ideal to run tests against a db that...
Besse asked 28/9, 2018 at 19:45

2

Solved

Now I have code like this: from rest_framework.test import APITestCase class MyTestClass(ApiTestCase): fixtures = ['some_fixtures.json', ] @pytest.mark.parametrize('field, reverse_ordering', ...

1

Solved

For the following piece of code: @pytest.fixture(scope="module") def dummy_article(request, db): return mixer.blend("core.article", title="this one price", internal_id=3000) def test_article_st...
Bicentenary asked 10/8, 2018 at 9:50

0

I am new to pytest, I am running a very simple test to assert a model creation, but running the test seems to take a substantial amount of time. I have maybe 10 models tops, none of which are incre...
Deterrent asked 1/8, 2018 at 2:18

4

I'm trying to write test cases for my django project but when I run "$ ./manage.py test" command its creating test database but its not creating any tables and I'm getting an error that table does...
Indecision asked 22/6, 2015 at 6:40

2

Solved

In setting up a ArchiveIndexView in Django I am able to successfully display a list of items in a model by navigating to the page myself. When going to write the test in pytest to verify navigati...
Obedience asked 9/1, 2018 at 11:8

2

Solved

I am setting up a very simple Django project and with a very simple test like: def test_name(self): t = Thing.objects.create(name='a') print(t.id) import time time.sleep(30) self.assertEqual(...
Tarra asked 25/1, 2018 at 22:41

2

Solved

I'm working on a Django project in which settings such as SECRET_KEY are defined in a .env file, and manage.py sets the environment variable using python-dotenv as follows: from dotenv import load...
Electrostatic asked 9/1, 2018 at 23:33

1

Solved

I am successfully put ssh-key to docker runner and it can git clone to do dependencies installation. If I use ordinary build-in python manage.py test it works fine. But I am now working with pyte...
Postbox asked 25/12, 2017 at 7:5

1

Solved

My problem is the one bellow. If I try to run the test, it says there is no database permission and that I have to add that fixture. The problem is that I have added that fixture to any possible me...
Docile asked 12/7, 2017 at 11:26

1

Solved

How can I set an environment variable with the location of the pytest.ini, tox.ini or setup.cfg for running pytest by default? I created a docker container with a volume pointing to my project dir...
Rangefinder asked 6/7, 2017 at 21:16

2

How can I persist data to DB when using pytest/pytest-django in a test-run of a Django application? I run pytest with py.test --nomigrations --reuse-db -s and the Postgres DB test_<configured_db...
Bawdyhouse asked 25/11, 2015 at 23:34

1

Solved

I am trying to run selenium with pytest for my Django project and execute the fixture setup/teardown. I have tried to follow the best practice using yield but I am getting an error : --- ERROR a...
Kawai asked 4/3, 2017 at 5:36

1

Solved

I want to test my views using data from postgres localhost database (with already loaded data). I'm using tox with pytest and pytest-django. My question: How to set up / connect to local database ...
Ocreate asked 2/3, 2017 at 15:16

© 2022 - 2024 — McMap. All rights reserved.