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_loader_reload_registry_for_given_content(self):
content = dedent("""
@step("print hello")
def printf():
print("hello")
""")
load_steps(PythonFile.parse("foo.py", content))
self.assertTrue(registry.is_implemented("print hello"))
content = dedent("""
@step("print world")
def printf():
print("hello")
""")
reload_steps('foo.py', content)
self.assertFalse(registry.is_implemented("print hello"))
self.assertTrue(registry.is_implemented("print world"))
self.load_content_steps('''\
from getgauge.python import step
@step('foo ')
def foo():
pass
''')
self.assertEqual(registry.is_implemented('foo {}'), True)
request.filePath = 'foo.py'
request.status = CacheFileRequest.CREATED
self.fs.create_file('foo.py')
processor.process_cache_file_request(request)
self.assertEqual(registry.is_implemented('foo {}'), True)
def test_loader_non_string_argument(self):
content = dedent("""
@step(100)
def printf(arg1):
print(arg1)
""")
load_steps(PythonFile.parse("foo.py", content))
self.assertFalse(registry.is_implemented("print hello {}"))
''')
request.filePath = 'foo.py'
request.content = dedent('''\
from getgauge.python import step
@step('foo ')
def foo():
pass
''')
request.status = CacheFileRequest.CHANGED
processor.process_cache_file_request(request)
self.assertEqual(registry.is_implemented('foo1'), False)
self.assertEqual(registry.is_implemented('foo {}'), True)
def test_loader_reload_registry_for_given_content_with_empty_arg(self):
content = dedent("""
@step("print hello <>")
def printf(arg1):
print(arg1)
""")
load_steps(PythonFile.parse("foo.py", content))
self.assertTrue(registry.is_implemented("print hello {}"))
print("hello")
""")
load_steps(PythonFile.parse("foo.py", content))
self.assertTrue(registry.is_implemented("print hello"))
content = dedent("""
@step("print world")
def printf():
print("hello")
""")
reload_steps('foo.py', content)
self.assertFalse(registry.is_implemented("print hello"))
self.assertTrue(registry.is_implemented("print world"))
''')
request.filePath = 'foo.py'
request.content = dedent('''\
from getgauge.python import step
@step('foo ')
def foo():
pass
''')
request.status = CacheFileRequest.OPENED
processor.process_cache_file_request(request)
self.assertEqual(registry.is_implemented('foo1'), False)
self.assertEqual(registry.is_implemented('foo {}'), True)
@step("print hello")
def printf():
print("hello")
@hello("some other decorator")
@step("print .")
def print_word(word):
print(word)
""")
load_steps(PythonFile.parse("foo.py", content))
self.assertTrue(registry.is_implemented("print hello"))
self.assertTrue(registry.is_implemented("print {}."))
self.assertFalse(registry.is_implemented("some other decorator"))
def validate_step(request):
response = StepValidateResponse()
response.isValid = True
if registry.is_implemented(request.stepText) is False:
response.errorType = StepValidateResponse.STEP_IMPLEMENTATION_NOT_FOUND
response.errorMessage = 'Step implementation not found'
response.isValid = False
response.suggestion = _impl_suggestion(
request.stepValue)
elif registry.has_multiple_impls(request.stepText):
response.isValid = False
response.errorType = StepValidateResponse.DUPLICATE_STEP_IMPLEMENTATION
response.suggestion = _duplicate_impl_suggestion(
request)
return response