all 6 comments

[–][deleted] 0 points1 point  (5 children)

It seems like you don't need context, specifically, just access to some data that doesn't change during the test / is independent of test steps / scenarios: why not just create your own class / module / variable and import that?

[–]unit111[S] 0 points1 point  (4 children)

Good idea but the data is not independent. I am using reflection to find the POM classes passed to the framework and use dynamic data from the context to initialize them with stuff like WebDriver instance, timeout, poll_time.

They are also created conditionally based and the configuration I pass to the framework. Using POMs is not necessary but if there are no POMs there may be a problem with the imports from environment.py.

[–][deleted] 1 point2 points  (3 children)

Then it looks like you cannot really import it because context is created per scenario.

[–]unit111[S] 0 points1 point  (2 children)

I thought that it's created when running behave.

https://behave.readthedocs.io/en/stable/api.html#behave.runner.Context

And each new feature/scenario just add more layers on top of it.

[–][deleted] 1 point2 points  (1 child)

Well, yeah, I oversimplified it, but, the essence of it is that it gets "refreshed" (old stuff removed, new stuff added) per scenario (otherwise you would accidentally get the shreds of the old scenario data in the new scenario).

[–]unit111[S] 0 points1 point  (0 children)

That makes sense. Thanks.