# Buggy code
def run(self):
    # Tell pytest to omit the body of this function from tracebacks
    __tracebackhide__ = True
    database_key = str_to_bytes(fully_qualified_name(self.test))
    self.start_time = time.time()
    global in_given
    runner = ConjectureRunner(
        self.evaluate_test_data,
        settings=self.settings,
        random=self.random,
        database_key=database_key,
    )

    if in_given or self.collector is None:
        runner.run()
    else:  # pragma: no cover
        in_given = True
        original_trace = sys.gettrace()
        try:
            sys.settrace(None)
            runner.run()
        finally:
            in_given = False
            sys.settrace(original_trace)
    note_engine_for_statistics(runner)
    run_time = time.time() - self.start_time
    timed_out = runner.exit_reason == ExitReason.timeout
    if runner.last_data is None:
        return
    if runner.interesting_examples:
        self.falsifying_examples = sorted(
            [d for d in runner.interesting_examples.values()],
            key=lambda d: sort_key(d.buffer),
            reverse=True,
        )
    else:
        if timed_out:
            note_deprecation(
                (
                    "Your tests are hitting the settings timeout (%.2fs). "
                    "This functionality will go away in a future release "
                    "and you should not rely on it. Instead, try setting "
                    "max_examples to be some value lower than %d (the number "
                    "of examples your test successfully ran here). Or, if you "
                    "would prefer your tests to run to completion, regardless "
                    "of how long they take, you can set the timeout value to "
                    "hypothesis.unlimited."
                )
                % (self.settings.timeout, runner.valid_examples),
                self.settings,
            )
        if runner.valid_examples < min(
            self.settings.min_satisfying_examples,
            self.settings.max_examples,
        ) and not (
            runner.exit_reason == ExitReason.finished and self.at_least_one_success
        ):
            if timed_out:
                raise Timeout(
                    (
                        "Ran out of time before finding a satisfying "
                        "example for "
                        "%s. Only found %d examples in " + "%.2fs."
                    )
                    % (
                        get_pretty_function_description(self.test),
                        runner.valid_examples,
                        run_time,
                    )
                )
            else:
                raise Unsatisfiable(
                    (
                        "Unable to satisfy assumptions of hypothesis "
                        "%s. Only %d examples considered "
                        "satisfied assumptions"
                    )
                    % (
                        get_pretty_function_description(self.test),
                        runner.valid_examples,
                    )
                )

    if not self.falsifying_examples:
        return

    flaky = 0

    self.__in_final_replay = True

    for falsifying_example in self.falsifying_examples:
        self.__was_flaky = False
        try:
            with self.settings:
                self.test_runner(
                    ConjectureData.for_buffer(falsifying_example.buffer),
                    reify_and_execute(
                        self.search_strategy,
                        self.test,
                        print_example=True,
                        is_final=True,
                    ),
                )
        except (UnsatisfiedAssumption, StopTest):
            report(traceback.format_exc())
            self.__flaky(
                "Unreliable assumption: An example which satisfied "
                "assumptions on the first run now fails it."
            )
        except BaseException:
            if len(self.falsifying_examples) <= 1:
                raise
            report(traceback.format_exc())
        else:
            if (
                isinstance(falsifying_example.__expected_exception, DeadlineExceeded)
                and self.__test_runtime is not None
            ):
                report(
                    (
                        "Unreliable test timings! On an initial run, this "
                        "test took %.2fms, which exceeded the deadline of "
                        "%.2fms, but on a subsequent run it took %.2f ms, "
                        "which did not. If you expect this sort of "
                        "variability in your test timings, consider turning "
                        "deadlines off for this test by setting deadline=None."
                    )
                    % (
                        falsifying_example.__expected_exception.runtime,
                        self.settings.deadline,
                        self.__test_runtime,
                    )
                )
            else:
                report(
                    "Failed to reproduce exception. Expected: \n"
                    + falsifying_example.__expected_traceback,
                )

            filter_message = (
                "Unreliable test data: Failed to reproduce a failure "
                "and then when it came to recreating the example in "
                "order to print the test data with a flaky result "
                "the example was filtered out (by e.g. a "
                "call to filter in your strategy) when we didn't "
                "expect it to be."
            )

            try:
                self.test_runner(
                    ConjectureData.for_buffer(falsifying_example.buffer),
                    reify_and_execute(
                        self.search_strategy,
                        test_is_flaky(self.test, self.repr_for_last_exception),
                        print_example=True,
                        is_final=True,
                    ),
                )
            except (UnsatisfiedAssumption, StopTest):
                self.__flaky(filter_message)
            except Flaky as e:
                if len(self.falsifying_examples) > 1:
                    self.__flaky(e.args[0])
                else:
                    raise

        if self.__was_flaky:
            flaky += 1

    # If we only have one example then we should have raised an error or
    # flaky prior to this point.
    assert len(self.falsifying_examples) > 1

    if flaky > 0:
        raise Flaky(
            (
                "Hypothesis found %d distinct failures, but %d of them "
                "exhibited some sort of flaky behaviour."
            )
            % (len(self.falsifying_examples), flaky)
        )
    else:
        raise MultipleFailures(
            ("Hypothesis found %d distinct failures.")
            % (
                len(
                    self.falsifying_examples,
                )
            )
        )


# Traceback (hypothesis.errors.Flaky)
Unreliable test timings! On an initial run, this test took 161.08ms, which exceeded the deadline of 125.00ms, but on a subsequent run it took 78.93 ms, which did not. If you expect this sort of variability in your test timings, consider turning deadlines off for this test by setting deadline=None.
Falsifying example: test_slow_draw(data=data(...))
You can add @seed(302934307671667531413257853548643485645) to this test to reproduce this failure.
Traceback (most recent call last):
File "slow_draw.py", line 24, in <module>
test_slow_draw()
File "slow_draw.py", line 15, in test_slow_draw
deadline=mid, timeout=unlimited, max_examples=10,
File "/home/david/scratch/v/lib/python3.5/site-packages/hypothesis/core.py", line 1008, in wrapped_test
state.run()
File "/home/david/scratch/v/lib/python3.5/site-packages/hypothesis/core.py", line 900, in run
print_example=True, is_final=True
File "/home/david/scratch/v/lib/python3.5/site-packages/hypothesis/executors.py", line 58, in default_new_style_executor
return function(data)
File "/home/david/scratch/v/lib/python3.5/site-packages/hypothesis/core.py", line 140, in run
return test(*args, **kwargs)
File "/home/david/scratch/v/lib/python3.5/site-packages/hypothesis/core.py", line 87, in test_or_flaky
) % (test.__name__, text_repr,))
hypothesis.errors.Flaky: Hypothesis test_slow_draw(data=data(...)) produces unreliable results: Falsified on the first call but did not on a subsequent one

# Fixed code
def run(data):
    with self.settings:
        with BuildContext(data, is_final=is_final):
            import random as rnd_module

            rnd_module.seed(0)
            args, kwargs = data.draw(self.search_strategy)
            if expected_failure is not None:
                text_repr[0] = arg_string(test, args, kwargs)

            if print_example:
                report(
                    lambda: "Falsifying example: %s(%s)"
                    % (test.__name__, arg_string(test, args, kwargs))
                )
            elif current_verbosity() >= Verbosity.verbose:
                report(
                    lambda: "Trying example: %s(%s)"
                    % (test.__name__, arg_string(test, args, kwargs))
                )

            if self.collector is None or not collect:
                return test(*args, **kwargs)
            else:  # pragma: no cover
                try:
                    self.collector.start()
                    return test(*args, **kwargs)
                finally:
                    self.collector.stop()