Category : pytest

I have a number of different custom transformer functions, and want to run a simple test (e.g. printing out the transformer) on all of these functions. I could write individual tests for each function, but thought there must be an easier way. I’ve looked at parameterizing the test but get: TypeError: ‘function’ object is not ..

Read more

After update pytest to pytest-remotedata-0.3.2, my tests stop working correctly. Still have the same issue: start_time = datetime.fromtimestamp(test_method._outcome.result.start_time) AttributeError: ‘TestCaseFunction’ object has no attribute ‘start_time’ code: def finish_test(self, test_method, driver=None): test_status = "OK" try: start_time = list(test_method._outcome.result.test_started_datetime_map.values())[-1] except AttributeError: start_time = datetime.fromtimestamp(test_method._outcome.result.start_time) Any ideas how i can replace start_time = datetime.fromtimestamp(test_method._outcome.result.start_time) Source: Python-3x..

Read more

I have a Flask application using Celery, and the async processing works fine when the app is running locally. However, when I try to test (pytest) a route that uses Celery tasks, I get this error: app/bp_dir/routes.py:12: in <module> from app import db, celery_tasks app/celery_tasks.py:13: in <module> @celery.task() E AttributeError: ‘NoneType’ object has no attribute ..

Read more

I’m on my way to simplify a set of tests by pytest by stacking parameters @pytest.mark.parametrize("option_a", ["-r", "-s"]) @pytest.mark.parametrize("option_b", ["–alpha", "–beta", "–gamma"]) def test_foo(option_a, option_b): assert option_a in ["-r", "-s"] As anticipated, the above MWE performs an exhaustive permutation: ======================================= test session starts ======================================= platform linux — Python 3.9.7, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 — /usr/bin/python3 cachedir: ..

Read more

i would like to list all scenarios and features described in the feature files for pytest_bdd. I tried the following: pytest –fixtures Lists the fixtures, including my ‘given,when, then’ but not the features/scenarios. Also tried this: pytest –collect-only that prints the test functions in the step definition file, bit nothing more. Any idea is welcome ..

Read more