Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_continue_on_failure(self):
step1 = registry.get_info_for('Step 1').impl
step2 = registry.get_info_for('Step 2').impl
self.assertEqual(
registry.is_continue_on_failure(step1, RuntimeError()), False)
self.assertEqual(
registry.is_continue_on_failure(step2, RuntimeError()), True)
def test_continue_on_failure(self):
step1 = registry.get_info_for('Step 1').impl
step2 = registry.get_info_for('Step 2').impl
self.assertEqual(
registry.is_continue_on_failure(step1, RuntimeError()), False)
self.assertEqual(
registry.is_continue_on_failure(step2, RuntimeError()), True)
def test_loader_populates_registry_for_with_aliases(self):
content = dedent("""
@step(["print hello", "say hello"])
def printf():
print("hello")
""")
load_steps(PythonFile.parse("foo.py", content))
self.assertTrue(registry.is_implemented("say hello"))
self.assertTrue(registry.get_info_for("say hello").has_alias)
def process_step_name_request(request):
response = StepNameResponse()
info = registry.get_info_for(request.stepValue)
response.isStepPresent = False
if info.step_text is not None:
response.isStepPresent = True
if info.has_alias:
for alias in info.aliases:
response.stepName.append(alias)
else:
response.stepName.append(info.step_text)
response.fileName = info.file_name
response.span.start = info.span['start']
response.span.startChar = info.span['startChar']
response.span.end = info.span['end']
response.span.endChar = info.span['endChar']
response.hasAlias = info.has_alias
return response
def refactor_step(request, response):
if registry.has_multiple_impls(request.oldStepValue.stepValue):
raise Exception('Multiple Implementation found for `{}`'.format(
request.oldStepValue.parameterizedStepValue
))
info = registry.get_info_for(request.oldStepValue.stepValue)
impl_file = PythonFile.parse(info.file_name)
diffs = impl_file.refactor_step(
info.step_text,
request.newStepValue.parameterizedStepValue,
_new_parameter_positions(request),
)
content = impl_file.get_code()
if request.saveChanges:
with open(info.file_name, 'w') as f:
f.write(content)
response.success = True
response.filesChanged.append(info.file_name)
response.fileChanges.add(
fileName=info.file_name,
fileContent=content, # FIXME: Remove deprecated field
diffs=[TextDiff(span=Span(**d[0]), content=d[1]) for d in diffs],
def GetStepName(self, request, context):
res = Message()
info = registry.get_info_for(request.stepValue)
processor.step_name_response(info, res)
return res.stepNameResponse
def process_execute_step_request(request):
params = []
for p in request.parameters:
params.append(Table(p.table) if p.parameterType in [
Parameter.Table, Parameter.Special_Table] else p.value)
response = create_execution_status_response()
info = registry.get_info_for(request.parsedStepText)
execute_method(params, info, response, registry.is_continue_on_failure)
return response