Skip to content
Advertisement

Tag: pytest

Pytest retry logic upon one unsuccessful test

In my pytest suite, I run plenty of iOS UI tests. Which comes with plenty of frustrating issues. Im experimenting with the use of a hook based retry logic. Essentially, I have a pytest_runtest_call hook, where I collect the output of a test via a yield, and do extra processing with that data. Based on the failed output of the

customize html table of pytest with docstring of the test

I have a pytest test function as below. I’d like to print this test_mytest.docstring in the html report as a column between test and duration columns. I could gather that the pytest_runtest_makereport() pytest.mark.hookwrapper could help. Is there any code snippets that I can use as a reference to make the modification Answer Fortunately the exact example is mention in the

How to use pytest fixture with fixture factory?

In scikit-learn, there is a function parametrize_with_checks() that is used as a pytest fixture factory–it returns a pytest.mark.parametrize fixture, and is called as a decorator with an iterable of estimators, e.g. My issue is that my list of estimators may change (or I may have multiple lists), and each list I am setting up in a fixture. Here is a

How to define a mock object inside a mock in python?

I have a class that contains another class in a variable. Now I want to write a unit-test and define a mock object. Therefore I define a fixture in conftest.py and monkeypatch it with the mock object. I now get a the desired mock object but the inner object is noch the mock object which I defined. The problem ist

Python mocking table schema

I have a simple python function that needs tested that looks like this: However, to test this, I don’t want to test with a real table – I would like to create a Mock schema within my test (and a mock client too). My test currently looks like this: However, when I print returned_schema, I get the following: <MagicMock name=’Client.get_table().schema’

Parametrizing fixtures and functions without combinations

Here’s the thing: I have an Array2D class that receives parameters ‘shape’ and ‘val’. The constructor is as follows: I would like to perform tests on this class. To do this I have declared a variable ARRAY_CONFIG, which lists parameters for different two-dimensional arrays. Here is an example: I have also defined other lists that store the expected values for

pytest throws exception while using ClickArguments SystemExit: 0

I am trying to run a test case for a python script. Test case is successful when I don’t use Click decorator and argument in python script method. But when I am using it, it gives SystemExit: 0. commands.py: tests/test_commands.py: When I run the test case: then the test fails with: The full output is: Answer Don’t run click commands

Load existing data catalog programmatically

I want to write pytest unit test in Kedro 0.17.5. They need to perform integrity checks on dataframes created by the pipeline. These dataframes are specified in the catalog.yml and already persisted successfully using kedro run. The catalog.yml is in conf/base. I have a test module test_my_dataframe.py in src/tests/pipelines/my_pipeline/. How can I load the data catalog based on my catalog.yml

Advertisement