pytest Questions
2
I have been using unittest.IsolatedAsyncioTestCase to test my async methods. I have been making use of setUpClass and asyncSetUp to create a fixture, and asyncTearDown to cleanup. This is all worki...
Lucubration asked 11/4, 2023 at 16:40
2
Solved
I have this file structure.
When ı wrote pytest in my terminal.
ı have this issue !
ModuleNotFoundError: No module named 'money_transactions_test'
Hint: make sure your test modules/packages have ...
Rania asked 19/5, 2022 at 22:34
5
I have been over and over the documentation, but I can not fine out how I get py.test to write to the log for tests that pass. For example if I run "py.test --resultlog=mylog.txt myPytest.py" mylog...
3
Solved
Does anybody know how to run Django Tests using pytest-django against an existing (e.g. production) database?
I know that in general, this is not what unit tests are supposed to do, but in my case...
Pola asked 4/1, 2018 at 13:51
3
Solved
There were already questions regarding this topic. Sometimes programmers put some __init__.py at some places, often it is said one should use absolute paths. However, I don't get it to work here:
H...
Bantam asked 3/1, 2022 at 18:49
3
Solved
I'm having trouble getting the VS Code PyTest code runner to work the way I'd like. It seems pytest options may be an all-or-nothing situation.
Is there any way to run different sets of PyTest opt...
Orogeny asked 26/5, 2020 at 0:24
3
Solved
I want to write my test using pytest and to be able to run them (individually) in IntelliJ. I have pytest installed, along with (obviously) Python plugin for the IDE.
My test file (tests/test_main...
Berga asked 23/3, 2020 at 19:41
2
I am trying to run a trace on a program that is executed with pytest.
I am trying the command
python3 -m trace -t pytest test_one.py
but it is giving me
Cannot run file 'pytest' because: [Errn...
2
Solved
I want to name the test dynamically during run-time when i run them with the @pytest.mark.parametrize("value",values_list) fixture.
for example:
values_list=['apple','tomatoes','potatoes']
@pytes...
Dmitri asked 20/4, 2020 at 8:10
3
Hi I am trying to run my tests parallely(pytest-xdist) on the azure pipelines.
Till now the tests were running perfectly fine.
Suddenly the pytest is throwing a weird error saying "unrecognize...
Inerrant asked 9/1, 2022 at 4:22
4
Solved
I created some unit tests and run them from the same file. For tests in the same file:
if __name__ == "__main__":
import pytest
pytest.main(['--tb=short', __file__])
For tests in another file:...
Sauder asked 2/1, 2019 at 15:58
2
Solved
def func1():
return 5
def func2(param1, param2):
var1 = func1()
return param1 + param2 + var1
I want to use pytest to test the second function by mocking the first, but I am not sure how to...
Nations asked 11/7, 2022 at 18:23
5
I'm trying out the one of the recommended python package layouts with the src directory.
My problem is when I run pytest from the command line my tests are not finding my python package. I trie...
3
Solved
I have a lamba handler that uses an environment variable. How can I set that value using pytest. I'm getting the error
tests/test_kinesis.py:3: in <module>
from runner import kinesis
runner/...
3
Solved
pytest fixtures can work on other fixtures by passing them in as argument:
@pytest.fixture(scope='module')
def wrapper_fixture1(fixture1):
fixture1.do_something()
return fixture1
Now I have mu...
13
Solved
I have PyTest setup in vs-code but none of the tests are being found even though running pytest from the command line works fine.
(I'm developing a Django app on Win10 using MiniConda and a Python...
Monoplegia asked 27/1, 2019 at 11:4
3
Solved
I have different test folders(packages). I want to setup and teardown some data for a specific package(folder).
The problem is set_up() is executed before running the test cases of that folder but...
Bohr asked 2/4, 2014 at 10:16
3
Solved
When running tests with py.test there is a --pdb option to enter pdb on failure.
Is there a similar way to enter the debugger when running the same test from within PyCharm?
3
Solved
In the Indirect parametrization example I want to type hint request.param indicating a specific type, a str for example.
The problem is since the argument to fixt must be the request fixture there ...
Salon asked 17/12, 2020 at 3:13
3
Solved
I am trying to debug my Python Pytest tests in VS Code, using the Testing Activity on the left bar. I am able to run my tests as expected, with some passing and some failing. I would like to debug ...
Disguise asked 9/4, 2022 at 20:39
1
I have tried everything I've been able to find, but I can't get tests to work when httpx AsyncClient is used.
I encountered two errors when running a test:
RuntimeError: This event loop is already...
Fibrosis asked 31/3, 2021 at 21:30
2
I want to write tests for my FastAPI endpoints
example for my code:
from fastapi import FastAPI
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/todos")
async def ge...
Selfpreservation asked 26/4, 2022 at 7:2
5
Solved
In Visual Studio Code, the test button on the left, the one that looks like a flask, has disappeared on my machine. I tried to run the command "Test: Run All Tests", but I get a message &...
Darell asked 13/4, 2021 at 9:0
2
Is there a way to define a mark in a PyTest fixture?
I am trying to disable slow tests when I specify -m "not slow" in pytest.
I have been able to disable individual tests, but not a fixt...
Earley asked 21/10, 2019 at 19:12
14
I am trying to find the coverage using coverage module for a django project but gets
Coverage.py warning: No data was collected. (no-data-collected)
My project folder has src and tests folders.
Wh...
Malachite asked 14/11, 2017 at 14:0
1 Next >
© 2022 - 2024 — McMap. All rights reserved.