How to use __flaky method in hypothesis

Best Python code snippet using hypothesis

core.py

Source:core.py Github

copy

Full Screen

...734 print_example=True, is_final=True735 ))736 except (UnsatisfiedAssumption, StopTest):737 report(traceback.format_exc())738 self.__flaky(739 'Unreliable assumption: An example which satisfied '740 'assumptions on the first run now fails it.'741 )742 except:743 if len(self.falsifying_examples) <= 1:744 raise745 raised_exception = True746 report(traceback.format_exc())747 if not raised_exception:748 if (749 isinstance(750 falsifying_example.__expected_exception,751 DeadlineExceeded752 ) and self.__test_runtime is not None753 ):754 report((755 'Unreliable test timings! On an initial run, this '756 'test took %.2fms, which exceeded the deadline of '757 '%.2fms, but on a subsequent run it took %.2f ms, '758 'which did not. If you expect this sort of '759 'variability in your test timings, consider turning '760 'deadlines off for this test by setting deadline=None.'761 ) % (762 falsifying_example.__expected_exception.runtime,763 self.settings.deadline, self.__test_runtime764 ))765 else:766 report(767 'Failed to reproduce exception. Expected: \n' +768 falsifying_example.__expected_traceback,769 )770 filter_message = (771 'Unreliable test data: Failed to reproduce a failure '772 'and then when it came to recreating the example in '773 'order to print the test data with a flaky result '774 'the example was filtered out (by e.g. a '775 'call to filter in your strategy) when we didn\'t '776 'expect it to be.'777 )778 try:779 self.test_runner(780 ConjectureData.for_buffer(falsifying_example.buffer),781 reify_and_execute(782 self.search_strategy,783 test_is_flaky(784 self.test, self.repr_for_last_exception),785 print_example=True, is_final=True786 ))787 except (UnsatisfiedAssumption, StopTest):788 self.__flaky(filter_message)789 except Flaky as e:790 if len(self.falsifying_examples) > 1:791 self.__flaky(e.args[0])792 else:793 raise794 if self.__was_flaky:795 flaky += 1796 # If we only have one example then we should have raised an error or797 # flaky prior to this point.798 assert len(self.falsifying_examples) > 1799 if flaky > 0:800 raise Flaky((801 'Hypothesis found %d distinct failures, but %d of them '802 'exhibited some sort of flaky behaviour.') % (803 len(self.falsifying_examples), flaky))804 else:805 raise MultipleFailures((806 'Hypothesis found %d distinct failures.') % (807 len(self.falsifying_examples,)))808 def __flaky(self, message):809 if len(self.falsifying_examples) <= 1:810 raise Flaky(message)811 else:812 self.__was_flaky = True813 report('Flaky example! ' + message)814def given(*given_arguments, **given_kwargs):815 """A decorator for turning a test function that accepts arguments into a816 randomized test.817 This is the main entry point to Hypothesis.818 """819 def run_test_with_generator(test):820 generator_arguments = tuple(given_arguments)821 generator_kwargs = dict(given_kwargs)822 original_argspec = getfullargspec(test)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful