-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/IVS-122 - No error handling for non-behave errors in production #322
Fix/IVS-122 - No error handling for non-behave errors in production #322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change, otherwise looks good!
features/environment.py
Outdated
if not 'Behave errors' in context.step.error_message: #exclude behave output from exception logging | ||
context.caught_exceptions.append(ExceptionSummary.from_context(context)) | ||
execution_mode = context.config.userdata.get('execution_mode') | ||
if execution_mode and execution_mode == 'ExecutionMode.TESTING': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if execution_mode and execution_mode == 'ExecutionMode.TESTING': | |
if execution_mode and execution_mode == ExecutionMode.TESTING: |
ExecutionModel is an enumeration, not a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It originally is, but the behave context stack outputs it as a string.
context.config.userdata.get('execution_mode')
'ExecutionMode.TESTING'
type(context.config.userdata.get('execution_mode'))
<class 'str'>
What we can do is how we solved this earlier in the code, with using eval
. That way, the variable is back to it's original enumeration data type.
eval(context.config.userdata.get('execution_mode'))
<ExecutionMode.TESTING: 0>
type(eval(context.config.userdata.get('execution_mode')))
<enum 'ExecutionMode'>
eval(context.config.userdata.get('execution_mode')) == ExecutionMode.TESTING
True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also bumped into this from time to time. Just a general recommendation from my side not to use eval().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, why? A reason I can come up with is that it would perhaps be safer to pass data around with the os environment rather than the behave stack.
os.environ["EXECUTION_MODE"] = execution_mode.name
And retrieve it;
execution_mode = ExecutionMode[os.environ.get('EXECUTION_MODE')]
execution_mode == ExecutionMode.TESTING
True
No description provided.