Esempio n. 1
0
def find_breaking_runner(state_machine_factory, settings=None):
    def is_breaking_run(runner):
        try:
            runner.run(state_machine_factory())
            return False
        except (InvalidDefinition, UnsatisfiedAssumption):
            raise
        except Exception:
            verbose_report(traceback.format_exc)
            return True
    if settings is None:
        try:
            settings = state_machine_factory.TestCase.settings
        except AttributeError:
            settings = Settings.default

    search_strategy = StateMachineSearchStrategy(settings)
    if settings.database is not None:
        storage = settings.database.storage(
            getattr(
                state_machine_factory, u'__name__',
                type(state_machine_factory).__name__))
    else:
        storage = None

    return find(
        search_strategy,
        is_breaking_run,
        settings=settings,
        storage=storage,
    )
Esempio n. 2
0
 def run():
     return find(
         definition,
         condition,
         settings=settings,
         random=random,
     )
Esempio n. 3
0
def find_breaking_runner(state_machine_factory, settings=None):
    def is_breaking_run(runner):
        try:
            runner.run(state_machine_factory())
            return False
        except (InvalidDefinition, UnsatisfiedAssumption):
            raise
        except Exception:
            verbose_report(traceback.format_exc)
            return True

    if settings is None:
        try:
            settings = state_machine_factory.TestCase.settings
        except AttributeError:
            settings = Settings.default

    search_strategy = StateMachineSearchStrategy(settings)
    if settings.database is not None:
        storage = settings.database.storage(
            getattr(state_machine_factory, '__name__',
                    type(state_machine_factory).__name__))
    else:
        storage = None

    return find(
        search_strategy,
        is_breaking_run,
        settings=settings,
        storage=storage,
    )
Esempio n. 4
0
 def find_breaking_runner(state_machine_class):
     def is_breaking_run(runner):
         try:
             runner.run(state_machine_class())
             return False
         except (InvalidDefinition, UnsatisfiedAssumption):
             raise
         except Exception:
             verbose_report(traceback.format_exc)
             return True
     return find(
         StateMachineSearchStrategy(
             state_machine_class.TestCase.settings
         ), is_breaking_run,
         state_machine_class.TestCase.settings,
     )
def find_breaking_runner(state_machine_factory, settings=None):
    def is_breaking_run(runner):
        try:
            runner.run(state_machine_factory())
            return False
        except (InvalidDefinition, UnsatisfiedAssumption):
            raise
        except Exception:
            verbose_report(traceback.format_exc)
            return True
    if settings is None:
        try:
            settings = state_machine_factory.TestCase.settings
        except AttributeError:
            settings = Settings.default

    return find(
        StateMachineSearchStrategy(
            settings
        ), is_breaking_run,
        settings,
    )
Esempio n. 6
0
def find_breaking_runner(state_machine_factory, settings=None):
    def is_breaking_run(runner):
        try:
            runner.run(state_machine_factory())
            return False
        except HypothesisException:
            raise
        except EXCEPTIONS_TO_FAIL:
            verbose_report(traceback.format_exc)
            return True

    if settings is None:
        try:
            settings = state_machine_factory.TestCase.settings
        except AttributeError:
            settings = Settings.default

    search_strategy = StateMachineSearchStrategy(settings)

    return find(search_strategy,
                is_breaking_run,
                settings=settings,
                database_key=state_machine_factory.__name__.encode('utf-8'))
Esempio n. 7
0
def find(strategy: SearchStrategy[Domain]) -> Domain:
    first_object_list = []

    def condition(object_: Any) -> bool:
        if first_object_list:
            return True
        else:
            first_object_list.append(object_)
            return False

    try:
        return core.find(strategy,
                         condition,
                         settings=settings(database=None,
                                           phases=tuple(set(Phase)
                                                        - {Phase.shrink})))
    except (NoSuchExample, Unsatisfiable) as search_error:
        try:
            result, = first_object_list
        except ValueError as unpacking_error:
            raise unpacking_error from search_error
        else:
            return result
Esempio n. 8
0
def find_breaking_runner(state_machine_factory, settings=None):
    def is_breaking_run(runner):
        try:
            runner.run(state_machine_factory())
            return False
        except HypothesisException:
            raise
        except Exception:
            verbose_report(traceback.format_exc)
            return True
    if settings is None:
        try:
            settings = state_machine_factory.TestCase.settings
        except AttributeError:
            settings = Settings.default

    search_strategy = StateMachineSearchStrategy(settings)

    return find(
        search_strategy,
        is_breaking_run,
        settings=settings,
        database_key=state_machine_factory.__name__.encode('utf-8')
    )
Esempio n. 9
0
 def run():
     return find(
         definition,
         condition,
         settings=settings
     )
Esempio n. 10
0
 def run():
     return find(definition, condition, settings=settings)
Esempio n. 11
0
def find(strategy: SearchStrategy) -> Any:
    return core.find(strategy, lambda _: True)