def note_deprecation(message, s=None): if s is None: s = settings.default assert s is not None verbosity = s.verbosity warning = HypothesisDeprecationWarning(message) if verbosity > Verbosity.quiet: warnings.warn(warning, stacklevel=3)
def note_deprecation(message: str, *, since: str, has_codemod: bool) -> None: if since != "RELEASEDAY": date = datetime.datetime.strptime(since, "%Y-%m-%d").date() assert datetime.date(2016, 1, 1) <= date if has_codemod: message += ( "\n The `hypothesis codemod` command-line tool can automatically " "refactor your code to fix this warning.") warnings.warn(HypothesisDeprecationWarning(message), stacklevel=2)
def note_deprecation(message, since, verbosity=None): # type: (str, str, Verbosity) -> None if verbosity is None: verbosity = settings.default.verbosity assert verbosity is not None if since != "RELEASEDAY": date = datetime.datetime.strptime(since, "%Y-%m-%d").date() assert datetime.date(2016, 1, 1) <= date warning = HypothesisDeprecationWarning(message) if verbosity > Verbosity.quiet: warnings.warn(warning, stacklevel=2)
def note_deprecation(message, s=None): # If *either* self or the current default are non-strict # then this should be an error. This is to handle e.g. the case # where defining a new setting while non-strict updates a # profile which is strict. This should not be an error, but # using the profile here would cause it to be one. if s is None: s = settings.default assert s is not None strict = settings.default.strict and s.strict verbosity = s.verbosity warning = HypothesisDeprecationWarning(message) if strict: raise warning elif verbosity > Verbosity.quiet: warnings.warn(warning, stacklevel=3)
def _get_default(): var = os.getenv('HYPOTHESIS_VERBOSITY_LEVEL') if var is not None: # pragma: no cover try: result = Verbosity[var] except KeyError: raise InvalidArgument('No such verbosity level %r' % (var, )) warnings.warn( HypothesisDeprecationWarning( 'The HYPOTHESIS_VERBOSITY_LEVEL environment variable is ' 'deprecated, and will be ignored by a future version of ' 'Hypothesis. Configure your verbosity level via a ' 'settings profile instead.')) return result return Verbosity.normal
def _get_default(): # type: () -> Verbosity var = os.getenv("HYPOTHESIS_VERBOSITY_LEVEL") if var is not None: # pragma: no cover try: result = Verbosity[var] except KeyError: raise InvalidArgument("No such verbosity level %r" % (var, )) warnings.warn( HypothesisDeprecationWarning( "The HYPOTHESIS_VERBOSITY_LEVEL environment variable is " "deprecated, and will be ignored by a future version of " "Hypothesis. Configure your verbosity level via a " "settings profile instead.")) return result return Verbosity.normal
def note_deprecation(message: str, *, since: str) -> None: if since != "RELEASEDAY": date = datetime.datetime.strptime(since, "%Y-%m-%d").date() assert datetime.date(2016, 1, 1) <= date warnings.warn(HypothesisDeprecationWarning(message), stacklevel=2)