In a project im working on we have a step where we export a csv before exporting we run a regression test step against the report using pytest. pytest is invoked using the following command –sample and –expectations are custom args defined in the conftest.py using the following when calling this code locally it works pytest finds the conf but
Tag: pytest
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,
Mock and patch class method and give its return value to another function
Here are my snippets So I want to test this instantiate_config with pytest. Here is my try: But this gives empty config dict. I don’t know is that possible – to mock Client().get_resources() to give it same value and that value to be passed automatically as argument to add_config_func. If it it not what is the best way to test
Publish Unit test in Python
I need to publish the result, but could not and have looked through this site and made research but still having issue to publish test result. Do I need to edit certain file similar to the cypress.json to be able to resolve the issue of Publishing. Both Unit test and the coveratge are not publishing any result and files are
django pytest how to test a view with argument(id)
i have a question regarding using pytest. These are my very 1st tests. I have 2 views which i want to test (simplest possible way). Views: Here are my tests: Urls: 1st test (menu view) is working properly 2nd test (cuisine details view) shows error I know i should probably put somethere ID argument but tried few options and havent
How to impose order on fixtures in pytest?
I am trying to use pytest-dependency to make fixtures happen in order, regardless of how they are named, and regardless of the order in which they appear in a test’s argument list. The reason I need this, is to create fixtures that require initializations, that depend on other fixtures that require initializations, and they must happen in order. I have
Pytest create multiple files with tmp_path fixture
I have a simple function which counts the files in a directory. I want to test this the following way. This works, but is of course very repetetive: Is there an easier way to write this? Desired: Answer Try just a simple for loop like
Testing the same function with different parameters
I am trying to test a function multiple times using different parameters. The return value should be True. What’s the best way to go about doing this in pytest? I want to avoid multiple functions acting as assert True wrappers e.g Answer Use @pytest.mark.parametrize()
ImportError in test files
I’ve seen a lot of questions that are similar to this but none of the solutions have worked for me. I’m getting an import error when trying to run pytest on a test package I’m developing to teach myself how to create python packages. Currently I have a python package that looks like and my test_module_a.py contains Running the command
Selenium Python Searching Element By 2 possible ID
I want to find the element using ID, but it seems that the web is sometimes changing the ID. There are 2 IDs, the first ID will make me possible to enter the email directly, but if the second ID occurs, I need to click a button first before entering my email. I’ve tried using if and else logic but