I’m trying to write a unit test for a python class that has a method similar to this: @staticmethod def __some_method(): doSomething… The issue I’m facing is that the __some_method doesn’t show up in the unit test file. Is there a way around this? Source: Python..
I’m trying to make a vending machine using python. money_box accepts currencies that are allowed in the machine and change accepts money that aren’t allowed in the machine. Whenever I run a pytest on the file, whichever function that is in the bottom gets an assertion error (either def test_money_box() or def test_change(). Is this ..
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 ..
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..
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 ..
I make e2e tests for an web app by using pytest and selenium. Everything is fine, but one thing I can’t figure out though spent day searching the web. I can’t make pytest_selenium_capture_debug work. I put it in conftest.py in the root of the test sources. Tests are run inside docker container. Firefox runs with ..
ive a folder with many tests, and when the pytest is running the output looks like it: tests/t1.py F [ 14%] tests/t2.py . [ 28%] tests/t3.py . [ 42%] tests/t4.py . [ 57%] tests/t5.py . [ 71%] tests/t6.py . [ 85%] tests/t7.py F [ 100%] I want to get rid of "tests/" in the output ..
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: ..
I have a few pytest files (begins with "test_"), each one of them tests another part of the system Now I want to create one file which supposes to run all the tests together. I read here how to run one python file from another, but it’s a bit different when the file is pytest ..
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 ..