Skip to main content

All Questions

Tagged with
-1 votes
1 answer
56 views

Django test TypeError: Field 'id' expected a number but got ()

I got this error 3 times in my code. I searched on other question and I didn't find anything that worked. Does anyone have any idea? Thank you. models.py class Exam(models.Model): code = models....
TheGoldenKiwi2's user avatar
0 votes
0 answers
33 views

Mocking a dictionary upon FastAPI router instantiation

Attempting to write tests for an existing route and running into some roadblocks. I'm trying to mock a dictionary that is loaded when a router is instantiated, but it seems like the @patch'd versions ...
Anthony's user avatar
  • 227
-1 votes
2 answers
52 views

AssertionError: 404 != 200 in django testing

I have test code, but it displays error: self.assertEquals(response.status_code, 200) AssertionError: 404 != 200 class TestViews(TestCase): def setUp(self): self.client = Client() ...
Fit's user avatar
  • 19
0 votes
0 answers
20 views

Tox tests working behaviour for changes in basepython field is a confusion

I have tox file which have a code like this [tox] envlist = py38,py39,py310,pep8 minversion = 3.1.0 skipsdist = False [testenv] basepython = python3 Earlier it was working like this, ...
S_Anuj's user avatar
  • 434
-1 votes
1 answer
60 views

Pytest ignoring certain parameters with multiple parametrize

Im wondering if there's any way of skipping parameter pairs in the example below: @pytest.mark.parametrize("foo", [1, 2, 3]) @pytest.mark.parametrize("bar", [4, 5, 6]) When ran ...
eilchner's user avatar
  • 121
0 votes
0 answers
31 views

Creating a model through the admin panel inside the test

I'm new to Python. I'm trying to create a test that will create an item inside the admin panel, but when I run the test I get: AssertionError: False is not true. Help me please class ItemAdminTest(...
Mir1a's user avatar
  • 7
0 votes
1 answer
47 views

How to parametrize test using different data from two different fixtures in pytest

I have several pytest fixtures: @pytest.fixture def articles_new(category): article_new_1 = ArticleFactory.create(category=category["category_1"], status=ArticleStatusChoices.NEW) ...
S.Shevchenko's user avatar
1 vote
1 answer
93 views

How to get exact value from fixture in @pytest.mark.parametrize

I use pytest fixture which return object {"article_new_1": article_new_1, "article_new_2": article_new_2}: @pytest.fixture def create_articles_new(create_categories): ...
S.Shevchenko's user avatar
0 votes
0 answers
45 views

Coverage.py does not mark some statements as "hit" even though they are actually covered

I have a problem when using coverage.py. I am testing a FastAPI application and cannot get to 100% test coverage due to that. I also cannot share the code, because it is a business logic and therefore ...
Виктор Валентинов's user avatar
1 vote
0 answers
16 views

How can you access the patch register in a python test?

I have python test which is part of a larger test suite. Inside that test there is a patch expression similar to this: def test_my_feature(): [...] with patch("my.module") as ...
David Jiménez Martínez's user avatar
2 votes
1 answer
53 views

Simulate stdout in fake subprocess.Popen

I would like to test a function, which invokes subprocess.Popen and captures stdout. In particular, I need to test stdout content physically captured in a file on disc without ever calling the actual ...
Maxim Ivanov's user avatar
0 votes
0 answers
32 views

Hypothesis + selenium + pytest issue

Not executing according to the set maximum number of times and Generate the same data repeatedly import pytest from selenium import webdriver from selenium.webdriver.common.keys import Keys from ...
haowumoqi's user avatar
1 vote
1 answer
50 views

statically inspect a python test suite

I have a (unittest-based) test suite for my python project. Here I have my test classes, with my test methods, etc... In (some of my) tests I call a function to initialize the scenarios of the tests. ...
Vito De Tullio's user avatar
0 votes
0 answers
21 views

Pass a test file to CherryPy in test

My CherryPy app has an upload endpoint, where a user can complete a form and pass some data along with an uploaded file. I'm interested in testing this endpoint, but I can't figure out how to create ...
lunchbox7804's user avatar
0 votes
2 answers
40 views

Mock from unittest not passed to Django view

def test_student_get(admin_user, some_model_fixture): client = Client() request_with_cookies = set_cookie(client, admin_user[0]) with patch('django.shortcuts.get_object_or_404') as ...
Iliya's user avatar
  • 5

15 30 50 per page