def test_hitting_timeout_is_deprecated(): with validate_deprecation(): @settings(timeout=0.1) @given(integers()) def test_slow_test_times_out(x): time.sleep(0.05) with validate_deprecation(): test_slow_test_times_out()
def test_hitting_timeout_is_deprecated(): with validate_deprecation(): @settings(timeout=0.1) @given(integers()) def test_slow_test_times_out(x): time.sleep(0.05) with validate_deprecation(): test_slow_test_times_out()
def test_raises_timeout_on_slow_test(): with validate_deprecation(): @given(integers()) @settings(timeout=0.01) def test_is_slow(x): time.sleep(0.02) with validate_deprecation(): with pytest.raises(Timeout): test_is_slow()
def test_raises_timeout_on_slow_test(): with validate_deprecation(): @given(integers()) @settings(timeout=0.01) def test_is_slow(x): time.sleep(0.02) with validate_deprecation(): with pytest.raises(Timeout): test_is_slow()
def test_slow_unsatisfiable_test(): with validate_deprecation(): @settings(timeout=0.1) @given(integers()) def test_slow_test_times_out(x): time.sleep(0.05) reject() with validate_deprecation(): with pytest.raises(Timeout): test_slow_test_times_out()
def test_slow_unsatisfiable_test(): with validate_deprecation(): @settings(timeout=0.1) @given(integers()) def test_slow_test_times_out(x): time.sleep(0.05) reject() with validate_deprecation(): with pytest.raises(Timeout): test_slow_test_times_out()
def test_given_twice_deprecated(): @given(booleans()) @given(integers()) def inner(a, b): pass with validate_deprecation(): inner()
def test_can_hit_timeout_in_find(): def f(x): time.sleep(100) return x >= 100 with pytest.raises(NoSuchExample): with validate_deprecation(): find(integers(), f, settings=timeout_settings)
def exampledatabase(request, tmpdir): if request.param == 'memory': return ExampleDatabase() if request.param == 'sql': with validate_deprecation(): return SQLiteExampleDatabase(str(tmpdir.join('example.db'))) if request.param == 'directory': return DirectoryBasedExampleDatabase(str(tmpdir.join('examples'))) assert False
def exampledatabase(request, tmpdir): if request.param == 'memory': return ExampleDatabase() if request.param == 'sql': with validate_deprecation(): return SQLiteExampleDatabase(str(tmpdir.join('example.db'))) if request.param == 'directory': return DirectoryBasedExampleDatabase(str(tmpdir.join('examples'))) assert False
def test_deprecated_determinism_with_database(dec): @dec @given(st.booleans()) def test(i): raise ValueError() with pytest.raises(ValueError): test() with validate_deprecation(): with pytest.raises(ValueError): test()
def test_deprecated_determinism_with_database(dec): @dec @given(st.booleans()) def test(i): raise ValueError() with pytest.raises(ValueError): test() with validate_deprecation(): with pytest.raises(ValueError): test()
def __init__(self): super(DatabaseComparison, self).__init__() self.tempd = tempfile.mkdtemp() exampledir = os.path.join(self.tempd, 'examples') self.dbs = [ DirectoryBasedExampleDatabase(exampledir), InMemoryExampleDatabase(), DirectoryBasedExampleDatabase(exampledir), ] with validate_deprecation(): self.dbs.append(SQLiteExampleDatabase(':memory:'))
with validate_deprecation(): @settings(timeout=0.1) @given(integers()) def test_slow_test_times_out(x): time.sleep(0.05) with validate_deprecation(): with pytest.raises(Unsatisfiable): test_slow_test_times_out() # Cheap hack to make test functions which fail on their second invocation calls = [0, 0, 0, 0] with validate_deprecation(): timeout_settings = settings(timeout=0.2, min_satisfying_examples=2) # The following tests exist to test that verifiers start their timeout # from when the test first executes, not from when it is defined. @fails @given(integers()) @timeout_settings def test_slow_failing_test_1(x): time.sleep(0.05) assert not calls[0] calls[0] = 1 @fails
def test_deprecated_target_consumes_bundle(): # It would be nicer to raise this error at runtime, but the internals make # this sadly impractical. Most InvalidDefinition errors happen at, well, # definition-time already anyway, so it's not *worse* than the status quo. with validate_deprecation(): rule(target=consumes(Bundle("b")))
def test_setting_use_coverage_is_deprecated(value): with validate_deprecation(): settings(use_coverage=value)
@settings(timeout=0.1) @given(integers()) def test_slow_test_times_out(x): time.sleep(0.05) reject() with validate_deprecation(): with pytest.raises(Timeout): test_slow_test_times_out() # Cheap hack to make test functions which fail on their second invocation calls = [0, 0, 0, 0] with validate_deprecation(): timeout_settings = settings(timeout=0.2) # The following tests exist to test that verifiers start their timeout # from when the test first executes, not from when it is defined. @checks_deprecated_behaviour @fails @given(integers()) @timeout_settings def test_slow_failing_test_1(x): time.sleep(0.05) assert not calls[0] calls[0] = 1
def __init__(self): with validate_deprecation(): super(BackendForTesting, self).__init__() self.create_db_if_needed() self.mirror = set()
def __init__(self): with validate_deprecation(): super(BackendForTesting, self).__init__() self.create_db_if_needed() self.mirror = set()
def test_setting_use_coverage_is_deprecated(value): with validate_deprecation(): settings(use_coverage=value)