def test_named_tuples_always_produce_named_tuples(): s = strategy(Litter(int,int)) for i in xrange(100): assert isinstance(s.produce(i, Flags()), Litter) for x in s.simplify(Litter(100,100)): assert isinstance(x, Litter)
def flags(self): r = set() self.add_flags_to(r) return Flags(r)
def generate_flags(): return Flags([ x for x in search_strategy.flags().flags if random() <= p])
def test_just_works(): s = strategy(ss.just("giving")) assert s.produce(10,Flags()) == "giving" assert s.simplify_such_that("giving", lambda _ : True) == "giving"
def test_can_disable_flags(): flags = Flags(["foo"]) assert flags.enabled("foo") flags2 = flags.with_disabled("foo") assert not flags2.enabled("foo")
def test_str_contains_flags(): assert "foo" in str(Flags(["foo"])) assert "foo" in str(Flags(["foo", "bar"])) assert "bar" in str(Flags(["foo", "bar"]))
def test_enabling_flags_leaves_original_unchanged(): flags = Flags() assert not flags.enabled("foo") flags2 = flags.with_enabled("foo") assert not flags.enabled("foo") assert flags2.enabled("foo")
def test_flags_not_enabled_by_default(): flags = Flags() assert not flags.enabled("foo")