Traceback occurs when step sentence is used with cardinality and standard types
See original GitHub issueI am using Python 2.7.10, MacOS Sierra version 10.12.4 and Radish-BDD version 0.6.2
>>> radish.__VERSION__
'0.6.2'
>>>
With the feature file of:
Feature: A test feature for issues with cardinality used in sentence parameters
A feature description here
Scenario: Fruit Consumption 1
Given I have a apple
When I eat the apple,pear,banana
Then I get lots of fiber
steps.py contents:
import re
from radish import given, when, then
@given(r'I have a {fruit:S}')
def my_step(step, fruit):
pass
@when(r'I {method:S} the {fruits:S+}')
def my_step(step, method, fruits):
pass
@then(r'I get lots of {what:S}')
def my_step(step, what):
pass
Then:
$ radish -b tests/stuff/ tests/stuff/features/ --early-exit
Error: 'S'
Traceback (most recent call last):
File ".../python-2.7.10/lib/python2.7/site-packages/radish/errororacle.py", line 59, in _decorator
return func(*args, **kwargs)
File ".../python-2.7.10/lib/python2.7/site-packages/radish/main.py", line 199, in main
return method(core)
File ".../python-2.7.10/lib/python2.7/site-packages/radish/main.py", line 66, in run_features
merge_steps(core.features, StepRegistry().steps)
File ".../python-2.7.10/lib/python2.7/site-packages/radish/matcher.py", line 63, in merge_steps
merge_step(step, steps)
File ".../python-2.7.10/lib/python2.7/site-packages/radish/matcher.py", line 73, in merge_step
match = match_step(step.context_sensitive_sentence, steps)
File ".../python-2.7.10/lib/python2.7/site-packages/radish/matcher.py", line 101, in match_step
parser = Parser(pattern, CustomTypeRegistry().custom_types)
File ".../python-2.7.10/lib/python2.7/site-packages/parse_type/cfparse.py", line 44, in __init__
missing = self.create_missing_types(schema, extra_types, type_builder)
File ".../python-2.7.10/lib/python2.7/site-packages/parse_type/cfparse.py", line 70, in create_missing_types
return type_builder.create_type_variants(missing, type_dict)
File ".../python-2.7.10/lib/python2.7/site-packages/parse_type/cardinality_field.py", line 163, in create_type_variants
type_variant = cls.create_type_variant(type_name, type_dict)
File ".../python-2.7.10/lib/python2.7/site-packages/parse_type/cardinality_field.py", line 135, in create_type_variant
raise MissingTypeError(primary_name)
MissingTypeError: 'S'
NOTE: The test runs without issues if the cardinality, e.g. ‘+’, is not specified in the step sentence decorator. Also, tried the cardinality with ‘d’ as well with similar message.
So,
Given the same feature file as above and the following changes to the steps.py:
...
@when(r'I {method:S} the {fruits:S}')
def my_step(step, method, fruits):
pass
...
Then:
$ radish -b tests/stuff/ tests/stuff/features/ --early-exit
Feature: A test feature for issues with cardinality used in sentence parameters # tests/stuff/features/stuff.feature
A feature description here
Scenario: Fruit Consumption 1
Given I have a apple
When I eat the apple,pear,banana
Then I get lots of fiber
1 features (1 passed)
1 scenarios (1 passed)
3 steps (3 passed)
Run 1496682564 finished within 0:3.009481 minutes
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Tutorial — radish 0.14.2 documentation
A Scenario contains one or more Steps. Each Scenario must have a unique sentence inside a Feature. Feature: My Awesome Feature In order...
Read more >What Is Cardinality in a Database? - Orange Matter - SolarWinds
In this sense, cardinality means whether a relationship is one-to-one, many-to-one, or many-to-many. So you're really talking about the ...
Read more >What Is Cardinality in a Database? (With Types and Examples)
Database administrators may use cardinality to count tables and values. In a database, cardinality usually represents the relationship between ...
Read more >Ordinal and One-Hot Encodings for Categorical Data
There are three common approaches for converting ordinal and categorical variables to numerical values. They are: Ordinal Encoding; One-Hot ...
Read more >Inheritance and Composition: A Python OOP Guide
In this step-by-step tutorial, you'll learn about inheritance and composition in Python. You'll improve your object-oriented programming (OOP) skills by ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@timofurrer I will see if I can make some time today to investigate.
I’m closing this - see the previously marked issue in parse_type.