radish-bdd / radish

Behavior Driven Development tooling for Python. The root from red to green.
https://radish-bdd.github.io
MIT License
181 stars 49 forks source link

Scenario Outlines do not inherit Feature context #408

Open edaine opened 4 years ago

edaine commented 4 years ago

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

[x] I have read the contributing guide lines at https://github.com/radish-bdd/radish/blob/master/.github/CONTRIBUTING.md

[x] I have read and respect the code of conduct at https://github.com/radish-bdd/radish/blob/master/.github/CODE_OF_CONDUCT.md

[x] I have searched the existing issues and I'm convinced that mine is new.

Describe the bug It seems that the Feature Context is not inherited with implementing steps using Scenario Outline but I cannot trace the cause.

Environment and Version

To Reproduce I have the following code in terrain.py:

@before.each_feature()
def initialize(feature):
    feature.context.index = 0

In one of the steps implementation, when step.parent.parent.context is invoked:

camera_index=step.parent.parent.context.index

I get the error:

AttributeError: 'Context' object has no attribute 'index'

I tried to print out the following:

print(step.context.__dict__)
print(step.parent.context.__dict__)
print(step.parent.parent.context.__dict__) 

And it yielded these:

{'constants': []}
{'constants': []}
{'constants': []}

Again, I only encounter this when the Scenario uses Scenario Outline and the parent contexts are accessed within the step implementation.

Expected behavior Contexts created in the Terrain can be normally accessed even if the Scenario is defined as "Scenario Outline".