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_undecorated_callback(self):
"""Process Task undecorated results are forwarded to the callback."""
task = process.task(target=undecorated, args=[1],
kwargs={'keyword_argument': 1},
callback=self.callback)
event.wait()
self.assertEqual(task.get(), 2)
@process.task(callback=callback)
def long_decorated_callback():
time.sleep(1)
@process.task
def decorated(argument, keyword_argument=0):
"""A docstring."""
return argument + keyword_argument
@process.task
def instmethod(self):
return self.b
def test_wrong_parameters(self):
"""Process Task raises ValueError if wrong params."""
self.assertRaises(ValueError, process.task, undecorated,
args=[1])
@process.task
def stcmethod():
return 2
@process.task(5, name='foo')
def wrong():
return
except Exception as error:
@process.task(callback=callback, timeout=0.2)
def timeout_decorated_callback():
time.sleep(1)
@process.task
def error_decorated():
raise Exception("BOOM!")