# Path: jasper/steps.py
# class Step(object):
#     """
#     The Step class is used as a wrapper around functions for testing behaviours.
#     """
#     def __init__(self, function, **kwargs):
#         """
#         Initialize a new Step object.
# 
#         :param function: The function this step will call when this step is run.
#         :param kwargs: Kwargs to call the given function with.
#         """
#         self.function = function
#         self.kwargs = kwargs
#         self.ran = False
#         self.passed = False
# 
#     async def run(self, context):
#         """
#         Run this step and record the results.
# 
#         :param context: A context object too pass into this steps function.
#         """
#         try:
#             if asyncio.iscoroutinefunction(self.function):
#                 await self.function(context, **self.kwargs)
#             else:
#                 self.function(context, **self.kwargs)
#         except Exception:
#             raise
#         else:
#             self.passed = True
#         finally:
#             self.ran = True
# 
# def step(func):
#     """
#     A decorator for wrapping a function into a Step object.
# 
#     :param func: The function to create a step out of.
#     :return: A function which when called will return a new instance of a Step object.
#     """
#     @wraps(func)
#     def wrapper(**kwargs):
#         return Step(func, **kwargs)
# 
#     return wrapper


from unittest import TestCase, mock
from jasper.steps import Step, step
import time
import asyncio
        self.slow_function_called = False
        self.slow_function_called_with = None

        def slow_function(context, sleep_time=0.5, fail=False):
            time.sleep(sleep_time)
            self.slow_function_called = True
            self.slow_function_called_with = {'context': context, 'sleep_time': sleep_time, 'fail': fail}

            if fail:
                raise Exception

        self.async_slow_function_called = False
        self.async_slow_function_called_with = None

        async def async_slow_function(context, sleep_time=0.5, fail=False):
            await asyncio.sleep(sleep_time)
            self.async_slow_function_called = True
            self.async_slow_function_called_with = {'context': context, 'sleep_time': sleep_time, 'fail': fail}

            if fail:
                raise Exception

        self.slow_function = slow_function
        self.async_slow_function = async_slow_function
        self.loop = asyncio.new_event_loop()

    def tearDown(self):
        self.loop.close()

    def test_init(self):

# Path: jasper/steps.py
# class Step(object):
#     """
#     The Step class is used as a wrapper around functions for testing behaviours.
#     """
#     def __init__(self, function, **kwargs):
#         """
#         Initialize a new Step object.
# 
#         :param function: The function this step will call when this step is run.
#         :param kwargs: Kwargs to call the given function with.
#         """
#         self.function = function
#         self.kwargs = kwargs
#         self.ran = False
#         self.passed = False
# 
#     async def run(self, context):
#         """
#         Run this step and record the results.
# 
#         :param context: A context object too pass into this steps function.
#         """
#         try:
#             if asyncio.iscoroutinefunction(self.function):
#                 await self.function(context, **self.kwargs)
#             else:
#                 self.function(context, **self.kwargs)
#         except Exception:
#             raise
#         else:
#             self.passed = True
#         finally:
#             self.ran = True
# 
# def step(func):
#     """
#     A decorator for wrapping a function into a Step object.
# 
#     :param func: The function to create a step out of.
#     :return: A function which when called will return a new instance of a Step object.
#     """
#     @wraps(func)
#     def wrapper(**kwargs):
#         return Step(func, **kwargs)
# 
#     return wrapper


# Path: tests/test_unit/test_step.py
from unittest import TestCase, mock
from jasper.steps import Step, step
import time
import asyncio

        self.slow_function_called = False
        self.slow_function_called_with = None

        def slow_function(context, sleep_time=0.5, fail=False):
            time.sleep(sleep_time)
            self.slow_function_called = True
            self.slow_function_called_with = {'context': context, 'sleep_time': sleep_time, 'fail': fail}

            if fail:
                raise Exception

        self.async_slow_function_called = False
        self.async_slow_function_called_with = None

        async def async_slow_function(context, sleep_time=0.5, fail=False):
            await asyncio.sleep(sleep_time)
            self.async_slow_function_called = True
            self.async_slow_function_called_with = {'context': context, 'sleep_time': sleep_time, 'fail': fail}

            if fail:
                raise Exception

        self.slow_function = slow_function
        self.async_slow_function = async_slow_function
        self.loop = asyncio.new_event_loop()

    def tearDown(self):
        self.loop.close()

    def test_init(self):

        some_step = Step(self.slow_function, sleep_time=0.1, fail=False)