tests/test-verify-repo-operations.py
changeset 28259 7829d0ba7459
parent 28258 fc7ee50a0d65
child 28279 c1fbc92d6238
equal deleted inserted replaced
28258:fc7ee50a0d65 28259:7829d0ba7459
    39 from hypothesis.errors import HypothesisException
    39 from hypothesis.errors import HypothesisException
    40 from hypothesis.stateful import (
    40 from hypothesis.stateful import (
    41     rule, RuleBasedStateMachine, Bundle, precondition)
    41     rule, RuleBasedStateMachine, Bundle, precondition)
    42 from hypothesis import settings, note, strategies as st
    42 from hypothesis import settings, note, strategies as st
    43 from hypothesis.configuration import set_hypothesis_home_dir
    43 from hypothesis.configuration import set_hypothesis_home_dir
       
    44 from hypothesis.database import ExampleDatabase
    44 
    45 
    45 testdir = os.path.abspath(os.environ["TESTDIR"])
    46 testdir = os.path.abspath(os.environ["TESTDIR"])
    46 
    47 
    47 # We store Hypothesis examples here rather in the temporary test directory
    48 # We store Hypothesis examples here rather in the temporary test directory
    48 # so that when rerunning a failing test this always results in refinding the
    49 # so that when rerunning a failing test this always results in refinding the
   528     def unshelve(self):
   529     def unshelve(self):
   529         self.commandused("shelve")
   530         self.commandused("shelve")
   530         with acceptableerrors("no shelved changes to apply"):
   531         with acceptableerrors("no shelved changes to apply"):
   531             self.hg("unshelve")
   532             self.hg("unshelve")
   532 
   533 
       
   534 class writeonlydatabase(ExampleDatabase):
       
   535     def __init__(self, underlying):
       
   536         super(ExampleDatabase, self).__init__()
       
   537         self.underlying = underlying
       
   538 
       
   539     def fetch(self, key):
       
   540         return ()
       
   541 
       
   542     def save(self, key, value):
       
   543         self.underlying.save(key, value)
       
   544 
       
   545     def delete(self, key, value):
       
   546         self.underlying.delete(key, value)
       
   547 
       
   548     def close(self):
       
   549         self.underlying.close()
       
   550 
   533 settings.register_profile(
   551 settings.register_profile(
   534     'default',  settings(
   552     'default',  settings(
   535         timeout=300,
   553         timeout=300,
   536         stateful_step_count=50,
   554         stateful_step_count=50,
   537         max_examples=10,
   555         max_examples=10,
   543         timeout=10,
   561         timeout=10,
   544         stateful_step_count=20,
   562         stateful_step_count=20,
   545         max_examples=5,
   563         max_examples=5,
   546         min_satisfying_examples=1,
   564         min_satisfying_examples=1,
   547         max_shrinks=0,
   565         max_shrinks=0,
       
   566     )
       
   567 )
       
   568 
       
   569 settings.register_profile(
       
   570     'continuous', settings(
       
   571         timeout=-1,
       
   572         stateful_step_count=1000,
       
   573         max_examples=10 ** 8,
       
   574         max_iterations=10 ** 8,
       
   575         database=writeonlydatabase(settings.default.database)
   548     )
   576     )
   549 )
   577 )
   550 
   578 
   551 settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
   579 settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
   552 
   580