Skip to content
Advertisement

Tag: unit-testing

How to unittest a datetime function

file.py test.py I get an Error: TypeError: ‘>’ not supported between instances of ‘MagicMock’ and ‘int’ Is there anyway to test this function? Probably the problem is with this part of the last line: (utc_date – namespace_created_date).days Answer I could reproduce and fix. Here is a working unittest file (assuming file.py is accessible): If I use date_now.datetime.utcnow.date.return_value = datetime.datetime(2022,1,1) I

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

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

unit test of function in different directory gives AttributeError: module has no attribute

What specific syntax must be changed below in order for a unit test running in one part of a file system to successfully test a function in a class that is located in a completely different part of a file system? The test file is located at C:pathtosome-test-classestest_an_example.py The class being tested is located at C:\completely\different\path\an_example.py The problem might be

Mocking sqlobject function call for test db

I am trying to mock sqlbuilder.func for test cases with pytest I successfully mocked sqlbuilder.func.TO_BASE64 with correct output but when I tried mocking sqlbuilder.func.FROM_UNIXTIME I didn’t get any error but the resulted output is incorrect with the generated query. Below is the minimal working example of the problem. models.py conftest.py test_ex1.py Current SQL: Expected SQL: Edit Example Answer By default,

Advertisement