Category : pytest-bdd

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

Assume I have a scenario similar to this: Scenario Outline: Example scenario Given the subprocess is running When I generate the input And I add <argument1> to the input And I add <argument2> to the input And this input is passed to the subprocess Then the output should match the <output> for <argument1> and <argument2> ..

Read more

I’m my flask app, I have an route/controller that creates something I call an entity: @api.route(‘/entities’, methods=[‘POST’]) def create_entity(): label = request.get_json()[‘label’] entity = entity_context.create(label) print(‘the result of creating the entity: ‘) print(entity) return entity After creating an entity, the following is printed: the result of creating the entity: {‘label’: ‘Uganda’, ‘_id’: ‘{"$oid": "5ff5df24bb80fcf812631c53"}’} I ..

Read more

I want to refactor some repeated code from a step_def file to a conftest.py file. Here’s what the step_def looks like: @scenario(‘../features/CLI.feature’, ‘store file in object database’) def test_file_stored_by_content_address(): pass @given("a file exists at some full path within a ugit dir", target_fixture="file_exists_at_path") def file_exists_at_path(file_within_ugit_dir): return file_within_ugit_dir @when("I enter ugit hash-object followed by that path") def ..

Read more

I have the following step definitions, which result in an error because the @given fixture is not found, even though it is defined in target_fixture: import pytest from pytest_bdd import scenario, given, when, then, parsers from admin import Admin @scenario(‘../features/Admin.feature’, ‘register a new user’) def test_admin(): pass @given(‘I’m logged in as an admin at <host_name> ..

Read more

I have a class called Tree and a class called Property in models.py: class Tree: def __init__(self, name=None): self.name = name self.properties = [] def get_name(self): return self.name def add_property(self, prop): if prop.__class__.__name__ != ‘Property’: raise TypeError(‘Only properties may be added as properties’) else: print(‘adding property: ‘ + str(prop)) self.properties.append(prop) def add_properties(self, arr): for label ..

Read more