Beispiel #1
0
def run():
    filterwarnings('error')
    filterwarnings('ignore', category=ImportWarning)
    filterwarnings('ignore', category=FutureWarning, module='pandas._version')

    # See https://github.com/numpy/numpy/pull/432
    filterwarnings('ignore', message='numpy.dtype size changed')
    filterwarnings('ignore', message='numpy.ufunc size changed')

    # Imported by Pandas in version 1.9, but fixed in later versions.
    filterwarnings(
        'ignore',
        message='Importing from numpy.testing.decorators is deprecated')
    filterwarnings(
        'ignore',
        message='Importing from numpy.testing.nosetester is deprecated')

    new_home = mkdtemp()
    set_hypothesis_home_dir(new_home)
    assert settings.default.database.path.startswith(new_home)

    charmap()
    assert os.path.exists(charmap_file()), charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, '%r == x.%s != s.%s == %r' % (
                v,
                s.name,
                s.name,
                s.default,
            )

    settings.register_profile(
        'default',
        settings(max_examples=10 if IN_COVERAGE_TESTS else not_set,
                 timeout=unlimited,
                 use_coverage=not IN_COVERAGE_TESTS))

    settings.register_profile('with_coverage',
                              settings(
                                  timeout=unlimited,
                                  use_coverage=True,
                              ))

    settings.register_profile('speedy', settings(max_examples=5, ))

    settings.register_profile('debug', settings(verbosity=Verbosity.debug))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
Beispiel #2
0
def run():
    filterwarnings('error')
    filterwarnings('ignore', category=ImportWarning)
    filterwarnings('ignore', category=FutureWarning, module='pandas._version')

    # Fixed in recent versions but allowed by pytest=3.0.0; see #1630
    filterwarnings('ignore', category=DeprecationWarning, module='pluggy')

    # See https://github.com/numpy/numpy/pull/432
    filterwarnings('ignore', message='numpy.dtype size changed')
    filterwarnings('ignore', message='numpy.ufunc size changed')

    # Imported by Pandas in version 1.9, but fixed in later versions.
    filterwarnings(
        'ignore',
        message='Importing from numpy.testing.decorators is deprecated'
    )
    filterwarnings(
        'ignore',
        message='Importing from numpy.testing.nosetester is deprecated'
    )

    new_home = mkdtemp()
    set_hypothesis_home_dir(new_home)
    assert settings.default.database.path.startswith(new_home)

    charmap()
    assert os.path.exists(charmap_file()), charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, '%r == x.%s != s.%s == %r' % (
                v, s.name, s.name, s.default,
            )

    settings.register_profile('default', settings(
        max_examples=10 if IN_COVERAGE_TESTS else not_set,
        timeout=unlimited,
    ))

    settings.register_profile(
        'speedy', settings(
            max_examples=5,
        ))

    settings.register_profile('debug', settings(verbosity=Verbosity.debug))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
Beispiel #3
0
def test_uses_cached_charmap():
    cm.charmap()

    # Reset the last-modified time of the cache file to a point in the past.
    mtime = int(time.time() - 1000)
    os.utime(cm.charmap_file(), (mtime, mtime))
    statinfo = os.stat(cm.charmap_file())
    assert statinfo.st_mtime == mtime

    # Force reload of charmap from cache file and check that mtime is unchanged.
    cm._charmap = None
    cm.charmap()
    statinfo = os.stat(cm.charmap_file())
    assert statinfo.st_mtime == mtime
Beispiel #4
0
def run():
    warnings.filterwarnings('error', category=UnicodeWarning)
    warnings.filterwarnings('error', category=HypothesisDeprecationWarning)

    set_hypothesis_home_dir(mkdtemp())

    charmap()
    assert os.path.exists(charmap_file())
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, '%r == x.%s != s.%s == %r' % (
                v,
                s.name,
                s.name,
                s.default,
            )

    settings.register_profile('default', settings(timeout=unlimited))

    settings.register_profile('speedy', settings(max_examples=5, ))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
def test_recreate_charmap():
    x = cm.charmap()
    assert x is cm.charmap()
    cm._charmap = None
    os.unlink(cm.charmap_file())
    y = cm.charmap()
    assert x is not y
    assert x == y
Beispiel #6
0
def test_recreate_charmap():
    x = cm.charmap()
    assert x is cm.charmap()
    cm._charmap = None
    os.unlink(cm.charmap_file())
    y = cm.charmap()
    assert x is not y
    assert x == y
Beispiel #7
0
def run():
    filterwarnings('error')
    filterwarnings('ignore', category=ImportWarning)
    filterwarnings('ignore', category=FutureWarning, module='pandas._version')
    # Only applies to Django 1.8, so this filter will go very soon!
    filterwarnings('ignore',
                   category=DeprecationWarning,
                   module='tests.django.toystore.models')

    set_hypothesis_home_dir(mkdtemp())

    charmap()
    assert os.path.exists(charmap_file()), charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, '%r == x.%s != s.%s == %r' % (
                v,
                s.name,
                s.name,
                s.default,
            )

    settings.register_profile(
        'default',
        settings(timeout=unlimited, use_coverage=not IN_COVERAGE_TESTS))

    settings.register_profile('with_coverage',
                              settings(
                                  timeout=unlimited,
                                  use_coverage=True,
                              ))

    settings.register_profile('speedy', settings(max_examples=5, ))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
def test_regenerate_broken_charmap_file():
    cm.charmap()
    file_loc = cm.charmap_file()

    with open(file_loc, 'wb'):
        pass

    cm._charmap = None
    cm.charmap()
Beispiel #9
0
def test_regenerate_broken_charmap_file():
    cm.charmap()
    file_loc = cm.charmap_file()

    with open(file_loc, "wb"):
        pass

    cm._charmap = None
    cm.charmap()
Beispiel #10
0
def run(deprecations_as_errors=True):
    warnings.filterwarnings('error', category=UnicodeWarning)
    # This catches deprecations in our dependencies, as well as internally
    # (because HypothesisDeprecationWarning subclasses DeprecationWarning)
    if deprecations_as_errors:  # disabled for old versions of Django
        warnings.filterwarnings('error', category=DeprecationWarning)

    set_hypothesis_home_dir(mkdtemp())

    charmap()
    assert os.path.exists(charmap_file()), charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, '%r == x.%s != s.%s == %r' % (
                v,
                s.name,
                s.name,
                s.default,
            )

    settings.register_profile(
        'default',
        settings(timeout=unlimited, use_coverage=not IN_COVERAGE_TESTS))

    settings.register_profile('with_coverage',
                              settings(
                                  timeout=unlimited,
                                  use_coverage=True,
                              ))

    settings.register_profile('speedy', settings(max_examples=5, ))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
Beispiel #11
0
def run():
    warnings.filterwarnings('error', category=UnicodeWarning)
    warnings.filterwarnings('error', category=HypothesisDeprecationWarning)

    set_hypothesis_home_dir(mkdtemp())

    charmap()
    assert os.path.exists(charmap_file()), charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, '%r == x.%s != s.%s == %r' % (
                v, s.name, s.name, s.default,
            )

    settings.register_profile('default', settings(
        timeout=unlimited, use_coverage=not (IN_COVERAGE_TESTS or PYPY)))

    settings.register_profile('with_coverage', settings(
        timeout=unlimited, use_coverage=True,
    ))

    settings.register_profile(
        'speedy', settings(
            max_examples=5,
        ))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
Beispiel #12
0
def test_error_writing_charmap_file_is_suppressed(monkeypatch):
    def broken_mkstemp(dir):
        raise RuntimeError()

    monkeypatch.setattr(tempfile, "mkstemp", broken_mkstemp)

    try:
        # Cache the charmap to avoid a performance hit the next time
        # somebody tries to use it.
        saved = cm._charmap
        cm._charmap = None
        os.unlink(cm.charmap_file())

        cm.charmap()
    finally:
        cm._charmap = saved
def test_error_writing_charmap_file_is_suppressed(monkeypatch):
    def broken_mkstemp(dir):
        raise RuntimeError()

    monkeypatch.setattr(tempfile, 'mkstemp', broken_mkstemp)

    try:
        # Cache the charmap to avoid a performance hit the next time
        # somebody tries to use it.
        saved = cm._charmap
        cm._charmap = None
        os.unlink(cm.charmap_file())

        cm.charmap()
    finally:
        cm._charmap = saved
Beispiel #14
0
def run():
    warnings.filterwarnings(u'error', category=UnicodeWarning)

    set_hypothesis_home_dir(mkdtemp())

    charmap()
    assert os.path.exists(charmap_file())
    assert isinstance(settings, type)

    settings.register_profile('default', settings(timeout=-1, strict=True))

    settings.register_profile('speedy', settings(
        timeout=1,
        max_examples=5,
    ))

    settings.register_profile('nonstrict', settings(strict=False))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
Beispiel #15
0
def run():
    warnings.filterwarnings(u'error', category=UnicodeWarning)

    set_hypothesis_home_dir(mkdtemp())

    charmap()
    assert os.path.exists(charmap_file())
    assert isinstance(settings, type)

    settings.register_profile(
        'default', settings(timeout=-1, strict=True)
    )

    settings.register_profile(
        'speedy', settings(
            timeout=1, max_examples=5,
        ))

    settings.register_profile(
        'nonstrict', settings(strict=False)
    )

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
def run():
    filterwarnings("error")
    filterwarnings("ignore", category=ImportWarning)
    filterwarnings("ignore", category=FutureWarning, module="pandas._version")

    # Fixed in recent versions but allowed by pytest=3.0.0; see #1630
    filterwarnings("ignore", category=DeprecationWarning, module="pluggy")

    # See https://github.com/numpy/numpy/pull/432
    filterwarnings("ignore", message="numpy.dtype size changed")
    filterwarnings("ignore", message="numpy.ufunc size changed")

    # See https://github.com/HypothesisWorks/hypothesis/issues/1674
    filterwarnings(
        "ignore",
        message=(
            "The virtualenv distutils package at .+ appears to be in the "
            "same location as the system distutils?"
        ),
        category=UserWarning,
    )

    # Imported by Pandas in version 1.9, but fixed in later versions.
    filterwarnings(
        "ignore", message="Importing from numpy.testing.decorators is deprecated"
    )
    filterwarnings(
        "ignore", message="Importing from numpy.testing.nosetester is deprecated"
    )

    new_home = mkdtemp()
    set_hypothesis_home_dir(new_home)
    assert settings.default.database.path.startswith(new_home)

    charmap()
    assert os.path.exists(charmap_file()), charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, "%r == x.%s != s.%s == %r" % (
                v,
                s.name,
                s.name,
                s.default,
            )

    settings.register_profile(
        "default", settings(max_examples=10 if IN_COVERAGE_TESTS else not_set)
    )

    settings.register_profile("speedy", settings(max_examples=5))

    settings.register_profile("debug", settings(verbosity=Verbosity.debug))

    settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default"))
Beispiel #17
0
def run():
    filterwarnings('error')
    filterwarnings('ignore', category=ImportWarning)
    filterwarnings('ignore', category=FutureWarning, module='pandas._version')

    # Fixed in recent versions but allowed by pytest=3.0.0; see #1630
    filterwarnings('ignore', category=DeprecationWarning, module='pluggy')

    # See https://github.com/numpy/numpy/pull/432
    filterwarnings('ignore', message='numpy.dtype size changed')
    filterwarnings('ignore', message='numpy.ufunc size changed')

    # See https://github.com/HypothesisWorks/hypothesis/issues/1674
    filterwarnings(
        'ignore',
        message=('The virtualenv distutils package at .+ appears to be in the '
                 'same location as the system distutils?'),
        category=UserWarning)

    # Imported by Pandas in version 1.9, but fixed in later versions.
    filterwarnings(
        'ignore',
        message='Importing from numpy.testing.decorators is deprecated')
    filterwarnings(
        'ignore',
        message='Importing from numpy.testing.nosetester is deprecated')

    new_home = mkdtemp()
    set_hypothesis_home_dir(new_home)
    assert settings.default.database.path.startswith(new_home)

    charmap()
    assert os.path.exists(charmap_file()), charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    import hypothesis._settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip
        # comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, '%r == x.%s != s.%s == %r' % (
                v,
                s.name,
                s.name,
                s.default,
            )

    settings.register_profile(
        'default',
        settings(
            max_examples=10 if IN_COVERAGE_TESTS else not_set,
            timeout=unlimited,
        ))

    settings.register_profile('speedy', settings(max_examples=5, ))

    settings.register_profile('debug', settings(verbosity=Verbosity.debug))

    settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))
Beispiel #18
0
def run():
    filterwarnings("error")
    filterwarnings("ignore", category=ImportWarning)
    filterwarnings("ignore", category=FutureWarning, module="pandas._version")

    # Fixed in recent versions but allowed by pytest=3.0.0; see #1630
    filterwarnings("ignore", category=DeprecationWarning, module="pluggy")

    # See https://github.com/numpy/numpy/pull/432
    filterwarnings("ignore", message="numpy.dtype size changed")
    filterwarnings("ignore", message="numpy.ufunc size changed")

    # See https://github.com/HypothesisWorks/hypothesis/issues/1674
    filterwarnings(
        "ignore",
        message=(
            "The virtualenv distutils package at .+ appears to be in the "
            "same location as the system distutils?"
        ),
        category=UserWarning,
    )

    # Imported by Pandas in version 1.9, but fixed in later versions.
    filterwarnings(
        "ignore", message="Importing from numpy.testing.decorators is deprecated"
    )
    filterwarnings(
        "ignore", message="Importing from numpy.testing.nosetester is deprecated"
    )

    # User-facing warning which does not apply to our own tests
    filterwarnings("ignore", category=NonInteractiveExampleWarning)

    new_home = mkdtemp()
    set_hypothesis_home_dir(new_home)
    assert settings.default.database.path.startswith(new_home)

    # Remove the cache because we might have saved this before setting the new home dir
    charmap._charmap = None
    charmap.charmap()
    assert os.path.exists(charmap.charmap_file()), charmap.charmap_file()
    assert isinstance(settings, type)

    # We do a smoke test here before we mess around with settings.
    x = settings()

    from hypothesis import _settings as settings_module

    for s in settings_module.all_settings.values():
        v = getattr(x, s.name)
        # Check if it has a dynamically defined default and if so skip comparison.
        if getattr(settings, s.name).show_default:
            assert v == s.default, "({!r} == x.{}) != (s.{} == {!r})".format(
                v, s.name, s.name, s.default
            )

    settings.register_profile(
        "default", settings(max_examples=20 if IN_COVERAGE_TESTS else not_set)
    )

    settings.register_profile("speedy", settings(max_examples=5))

    settings.register_profile("debug", settings(verbosity=Verbosity.debug))

    settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default"))