All Questions
716
questions
0
votes
0
answers
29
views
Django Internationalization test error:Couldn't retrieve redirection page
I wrote a blog project in Django,in some pages i used loginrequierdmixin to make sure user is loged in but in test i got error
test:
def test_get_profile_unauthenticated(self):
response = ...
0
votes
1
answer
28
views
How to test Amazon Athena queries
I have a rather complicated Athena query, which I would like to test on a local machine without connecting to Athena. I specified some mock data for testing purposes, and I was hoping that I could use ...
-1
votes
1
answer
27
views
Flask unit test failing due to FileNotFoundError for private key file [duplicate]
I'm trying to run unit tests on a Flask application that utilizes public and private keys for JWT token generation. However, when running my unit tests, I'm getting a FileNotFoundError indicating that ...
0
votes
1
answer
46
views
Mock patching an endpoint unittest that makes several requests to third party
I have a single endpoint written using django ninja. This endpoint executes a crawler that performs several requests. The sequence of requests has 3 different routines depending on whether or not the ...
0
votes
0
answers
42
views
Python unittest how to mock function which external function is defined in __init__.py
I would like to test my_func2 that is calling my_func1. I would like to mock my_func1, but I don't know how can I do it when my_func2 is imported in my_package.__init__.py. When I delete that import, ...
0
votes
1
answer
59
views
pytest fixtures in nested Classes
I have written the following testcase using pytest.
import pytest
data_arg = ["arg1", "arg2"]
class TestParentClass1:
@pytest.fixture(scope="class", params=data_arg,...
1
vote
1
answer
49
views
Increasing test coverage for files I didn't write
I have written a python program that calculates various statistical values of a given list of integers and the range of values. Now, I am trying to write a test file for the program that can achieve &...
0
votes
3
answers
55
views
Pytest: When writing many assert statements in the same test function, some of it fails, but how to know which assert statement/s is causing failure?
Test file :
from RansomNote import Solution
def test_canConstruct():
sol = Solution()
assert sol.canConstruct('aa', 'aab') == True
assert sol.canConstruct('xx','aaabc') == True
assert ...
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. ...
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 ...
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 ...
1
vote
0
answers
55
views
Python unittest/pytest tests priority
i have many unittests in my project each independent from another, however i would like to run the tests in parallel on several cores and in order to get the most out of it, it's necessary that the ...
1
vote
1
answer
36
views
Python ModuleNotFoundError when running tests
I have a Python program that runs correctly as expected, but for some reason I am not able to execute the tests.
In the folder hierarchy, tests is a sibling folder of src and the error I got when ...
0
votes
0
answers
44
views
Using pytest for OOPS where one class calls another and calls another
I am a noob at writing unit testing and I have not been able to find the answer anywhere for the following purpose
class xLoader:
def __init__(self, config, request_id,logger, mongo_obj,data_in):
...
1
vote
0
answers
33
views
Is it problematic to write tests for my lexer and then use that lexer to generate data for tests for my parser?
I'm writing a small transpiler. I've written extensive tests for my lexer. But writing tests for my parser is much more difficult because the parser needs to take in a List[Token] while the lexer ...