All Questions
3,541
questions
1
vote
2
answers
63
views
How to mock sqlalchemy's async session?
Code snippet
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
engine = create_async_engine(url="")
session_maker = async_sessionmaker(engine)
How can I mock the ...
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
0
answers
28
views
FastAPI dependency is not getting overriden [SOLVED] [closed]
I'm trying to run some tests with pytest against the API but my dependency override is not working. The root app is in my 'main' file and the endpoints are in a 'routers' file. I also have a separate '...
21
votes
1
answer
16k
views
Django Test Client post() returns 302 despite error on view's post()
I'm currently writing up some basic tests to ensure pages in a medium sized Django application are GETting and POSTing correctly. However, using django.test.client.Client isn't reliably failing when ...
6
votes
1
answer
6k
views
Mock superclass __init__ method or superclass as a whole for testing
I want to test a Python class I wrote, which is like the following:
from external_library import GenericClass
class SpecificClass(GenericClass):
def __init__(self, a, b, c):
super(...
2
votes
3
answers
5k
views
Pytest best practice to setup and teardown before and after all tests
Got a pytest script containing roughly 50 tests in 5 different files.
I need to setup a setup function that will run once before test are ran and then another one after all test are done ( pass or ...
1
vote
0
answers
23
views
mocking out imported objects in Python
Lets say there is a module headache that defines an object that is then imported and used by code I want to test:
# defined in headache/__init__.py
problem = Problem()
then it's imported by Foo:
# ...
71
votes
8
answers
43k
views
Python - Testing an abstract base class
I am looking for ways / best practices on testing methods defined in an abstract base class. One thing I can think of directly is performing the test on all concrete subclasses of the base class, but ...
1
vote
1
answer
24
views
Cannot mock the method in dependency module correctly in Python
Here is my project structure
|-- project
|-- util.py
|-- main.py
|-- tests
|-- test_main.py
In the main.py file I reference the function in util.py
from util import rename
def ...
1
vote
1
answer
131
views
Robot Framework is Automatically closing the browser
I am new to Robot and have this simple code from a tutorial. The code is supposed open chrome and visit the login page of this website. It does that, however, it closes the browser automatically. I've ...
5
votes
2
answers
1k
views
Django testing views - getting error - DiscoverRunner.run_tests() takes 2 positional arguments but 3 were given
I use Django framework to create basic web application. I started to write tests for my views. I followed the django documentation and fixed some issues along the way. But now I am stuck - I don't ...
32
votes
2
answers
33k
views
pytest assert message customization with variable introspection
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 status ...
0
votes
0
answers
28
views
How to list all futures that are being polled inside specific event loop when running pytest?
I'm running multiple pytest tests.
I have 1 specific test case, which works fine when executed alone, but when large amount of previous tests are being executed, this particular test gets stuck when ...
0
votes
5
answers
1k
views
How to fix a warning in pytest?
I do tests using py test. There is some kind of warning in the terminal, so I could just skip it, but I would like to remove it from the terminal.
RemovedInDjango50Warning: The USE_L10N setting is ...