Skip to main content

All Questions

Tagged with
1 vote
0 answers
21 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: # ...
solyd's user avatar
  • 792
1 vote
1 answer
47 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 ...
Michael Xia's user avatar
0 votes
0 answers
26 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 ...
Grzegorz Limanówka's user avatar
1 vote
1 answer
21 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 ...
hh54188's user avatar
  • 15.4k
1 vote
1 answer
102 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 ...
User9123's user avatar
  • 745
0 votes
0 answers
39 views

Why python testing always import the file in another module implicitly

Current I have two files in the same folder, in the source file I import the dlt module # File: pipeline.py import dlt Another is a test file which import nothing from the source file yet: import ...
hh54188's user avatar
  • 15.4k
1 vote
1 answer
27 views

Django session in tests

everyone! I can't figure out how the sessions work in Django. I have a shop, an anonymous user's shopping cart is bound to session_key. The session key is taken from the request object. def ...
Андрей's user avatar
0 votes
0 answers
23 views

Why 'coverage' considers all of my class-based-views as tested?

I'm just learning django testing. When I use 'Coverage' module to check which parts of my code is tested, it considers almost all of class-based-views as tested while I have commented out all of my ...
mohsenof's user avatar
  • 109
0 votes
1 answer
33 views

AssertionError while testing forms.py in Django

I tried to test forms.py in Django which has LeadForm class. Here, is the models.py class Lead(TimestampedModel): """leads for LIVE courses""" course = models....
Keerthana Baskar's user avatar
-1 votes
1 answer
25 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 ...
KauaKing's user avatar
0 votes
0 answers
22 views

testing django oauth2_provider authentication endpoint

I need to test o/token endpoint of the oauth2_provider. I wrote the test in pytest. I think I considered every thing but I get invalid_client error. The code: factory: class UserApplicationFactory(...
Mosy Mosy's user avatar
0 votes
0 answers
43 views

How to parse step definition code for projects using Cucumber?

I'm working on a project where I want to evaluate how Behavior Driven Development is being used. I want to extract Gherkin steps from .feature files and match the underlying step definition code. For ...
Uncle Ben's user avatar
1 vote
1 answer
28 views

DRF test user sign-in, error inactive user

I have view for authentfication: class UserViewSet(viewsets.ViewSet): @method_decorator(sensitive_variables("password")) @action(url_path="sign-in", detail=False, methods=[&...
Андрей's user avatar
0 votes
0 answers
38 views

"AssertionError: Expected 'show' to have been called once" when trying to mock plt.show()

I am currently trying to design some tests to run with pytest for a GUI. The GUI has a button that plots a graph on click. I want to make sure the button does indeed generate a graph. At this stage, I ...
DracoArtist's user avatar
2 votes
0 answers
27 views

Changing the scope of a pytest fixture to a larger one for a single module

I have a pytest fixture defined in conftest.py that looks like this: @pytest.fixture(scope="function") def setup_multiple(create, delete): @contextlib.contextmanager def f(type, num=...
eilchner's user avatar
  • 121

15 30 50 per page
1
2 3 4 5
237