Beispiel #1
0
 def breaking_example(cls):
     test_run = hypothesis.falsify(TestRun.run, cls)[0]
     result = []
     for f, args, kwargs in test_run:
         args, kwargs = convert_keyword_arguments(f, (None,) + args, kwargs)
         args = args[1:]
         result.append((f.__name__,) + args)
     return result
Beispiel #2
0
 def breaking_example(cls):
     test_run = hypothesis.falsify(TestRun.run, cls)[0]
     return [(f.__name__, ) + args for f, args in test_run]
Beispiel #3
0
def my_falsify(name, *args):
    print name + ": "
    try:
        print falsify(*args)
    except Exception, e:
        print e
Beispiel #4
0
def test_can_generate_utc():
    falsify(lambda d: assume(d.tzinfo) and d.tzinfo.zone != 'UTC', datetime)
Beispiel #5
0
def test_can_find_after_the_year_2000():
    falsify(lambda x: x.year > 2000, datetime)
Beispiel #6
0
def test_can_find_before_the_year_2000():
    falsify(lambda x: x.year < 2000, datetime)
Beispiel #7
0
def test_can_generate_non_naive_datetime():
    falsify(lambda d: not d.tzinfo, datetime)
Beispiel #8
0
def test_can_find_christmas():
    falsify(lambda d: assume(d.month == 12) and d.day == 25, datetime)
Beispiel #9
0
def test_simplifies_towards_midnight():
    d = falsify(lambda x: False, datetime)[0]
    assert d.hour == 0
    assert d.minute == 0
    assert d.second == 0
    assert d.microsecond == 0
Beispiel #10
0
def test_can_find_on_the_minute():
    falsify(lambda x: x.second != 0, datetime)
Beispiel #11
0
def test_can_find_february_29():
    falsify(lambda d: assume(d.month == 2) and (d.day != 29), datetime)
Beispiel #12
0
def test_can_find_non_midnight():
    falsify(lambda x: x.hour == 0, datetime)
Beispiel #13
0
def test_can_find_midnight():
    falsify(lambda x: not (x.hour == 0 and x.minute == 0 and x.second == 0),
            datetime)
Beispiel #14
0
def test_can_find_each_month():
    for i in hrange(1, 12):
        falsify(lambda x: x.month != i, datetime)
 def breaking_example(cls):
     test_run = hypothesis.falsify(TestRun.run, cls)[0]
     return [(f.__name__,) + args for f, args in test_run]
Beispiel #16
0
def test_simplifies_towards_2000():
    d = falsify(lambda x: x.year <= 2000, datetime)[0]
    assert d.year == 2001
    d = falsify(lambda x: x.year >= 2000, datetime)[0]
    assert d.year == 1999
Beispiel #17
0
def test_cannot_save_an_example_in_the_wrong_format():
    example = falsify(TestRun.run, IsBadAndShouldFeelBad)[0]
    converter = ConverterTable.default().specification_for(
        IsBadButItsNotMyFault)
    with pytest.raises(WrongFormat):
        converter.to_basic(example)
def falsify(name, *args):
    print(name + ": ")
    try:
        print(hypothesis.falsify(*args))
    except Exception as e:
        print(e)