Questions tagged [pytest]
For questions about the pytest Python testing tool. Please also add the [python] tag for questions tagged with [pytest].
pytest
10,449
questions
0
votes
1
answer
12
views
Calling module from jupyter notebook inside of poetry project reults in 'No module named' error
I'm working on a module with poetry with a directory structure like
./
/my_module
(module files)
/tests
test_thing.py
/jupyter
demo.ipynb
In the test files and jupyter ...
2
votes
0
answers
9
views
Method `new_page` of `BrowserContext` doesn`t work as expected in `Playwright`
I use playwright with pytest. Here are content of my coftest.py file and file with tests test_keplr.py. For some reason, method new_page works as expected in fixture context_use_args_async, but fails ...
0
votes
0
answers
24
views
How to capture call inside a with block?
I have some code with a testcase for it. It works fine.
import pysftp
from unittest import mock
remote_file_name = 'remote_file_name'
local_path = 'local/path/to/file'
def open_sftp_connection(...
0
votes
1
answer
20
views
Mocking or monkey patching a slow loading resource that loads on import
I have 1 file which loads a particular resource ( from a file ) that takes a while to load.
I have a function in another file which uses that resource by importing it first. When that resource is ...
-2
votes
0
answers
9
views
" TypeError: test_multiple_input.<locals>.<lambda>() missing 1 required positional argument: '_' main.py:6: TypeError", and I dont even know why
OK so I am creating Calculator using TDD approach. So I have created a stub which accepts multiple inputs of numbers,stub stops accepting it when I hit "Enter", so for test I am using pytest ...
-4
votes
0
answers
43
views
Why does assert statement applied to float(0) gives an error? [duplicate]
I am writing some tests for my code in Python in which I am using a library called pytest. It generally uses assert statements to evaluate a result. I have this code where I figure out if a given ...
0
votes
0
answers
21
views
How to capture Errors from Firefox browser console using Playwright Python
I want to capture console logs from Firefox web browser using Playwright Python and attach the same to Allure Report.
I am able to fetch Warnings, Logs, Info and Debug messages from browser console, ...
-1
votes
0
answers
18
views
how to handle no collectors found error for pytest framework
i have written pytest framework for my exisiting code , have written for specific function of reset chat where i have written method and wanted to run but there is error found no collectors for C:\...
0
votes
0
answers
8
views
How do I use grpcio-testing with pytest not unittest
I use pytest so I'm not using unittest or grouping my tests in a TestCase class.
All examples of this library I see use it this way:
class TestCase(unittest.TestCase):
def __init__(self, ...
0
votes
0
answers
13
views
Flask API Pytest Unit Tests Failing Due to Pyodbc
I’m having some issues with using Pytest. My Flask API uses pyodbc to talk to a MSSQL server db. The API runs in a Docker container and I'm running this on my Mac.
I have a unit test for a healthcheck ...
0
votes
1
answer
26
views
pytest-bdd splinter Failed to establish a new connection: [WinError 10061]
I'm trying to set up a pytest-bdd splinter test automation framework.
I have three scenarios in a feature file and the related steps definitions in a .py file.
In my conftest.py file I'm trying to use ...
0
votes
1
answer
32
views
automatic cleanup of postgres db after each test
I have sqlalchemy application that talks with a postgres db. I want to do some "integration tests" using testcontainers and trying the various scenarios.
just to make things simple, let's ...
-2
votes
0
answers
36
views
Why should I use specific imports instead of import * in Python? [duplicate]
I am working on a Python project and currently using the following import statement to bring in all fixtures from my conftest.py file:
from backend_tests.conftest import *
However, I've read that it ...
-2
votes
1
answer
61
views
Need help/understanding test functions with pytest
I need help creating test function that can be executed by pytest. I have created one and it passed but I need to test for each function I created and don't know how to do that. I have tried using ...
-1
votes
0
answers
21
views
How Pytest resolves imports
Here is my folder structure
/root
/app
__init__.py
/main.py
/tests
test_something.py (from app.main import ...)
When I run pytest inside /root or /root/tests, I get the error message &...