Hypothesis

Latest version: v6.100.1

Safety actively analyzes 621960 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 189 of 195

1.6.0

Not secure
------------------


This is a smallish release designed to fix a number of bugs and smooth out
some weird behaviours.

* Fix a critical bug in flatmap where it would reuse old strategies. If all
your flatmap code was pure you're fine. If it's not, I'm surprised it's
working at all. In particular if you want to use flatmap with django models,
you desperately need to upgrade to this version.
* flatmap simplification performance should now be better in some cases where
it previously had to redo work.
* Fix for a bug where invalid unicode data with surrogates could be generated
during simplification (it was already filtered out during actual generation).
* The Hypothesis database is now keyed off the name of the test instead of the
type of data. This makes much more sense now with the new strategies API and
is generally more robust. This means you will lose old examples on upgrade.
* The database will now not delete values which fail to deserialize correctly,
just skip them. This is to handle cases where multiple incompatible strategies
share the same key.
* find now also saves and loads values from the database, keyed off a hash of the
function you're finding from.
* Stateful tests now serialize and load values from the database. They should have
before, really. This was a bug.
* Passing a different verbosity level into a test would not have worked entirely
correctly, leaving off some messages. This is now fixed.
* Fix a bug where derandomized tests with unicode characters in the function
body would error on Python 2.7.

1.5

<https://github.com/samuelcolvin/pydantic/pull/1034>`__).

1.5.0

Not secure
------------------


Codename: Strategic withdrawal.

The purpose of this release is a radical simplification of the API for building
strategies. Instead of the old approach of strategy.extend and things that
get converted to strategies, you just build strategies directly.

The old method of defining strategies will still work until Hypothesis 2.0,
because it's a major breaking change, but will now emit deprecation warnings.

The new API is also a lot more powerful as the functions for defining strategies
give you a lot of dials to turn. See :doc:`the updated data section <data>` for
details.

Other changes:

* Mixing keyword and positional arguments in a call to given is deprecated as well.
* There is a new setting called 'strict'. When set to True, Hypothesis will raise
warnings instead of merely printing them. Turning it on by default is inadvisable because
it means that Hypothesis minor releases can break your code, but it may be useful for
making sure you catch all uses of deprecated APIs.
* max_examples in settings is now interpreted as meaning the maximum number
of unique (ish) examples satisfying assumptions. A new setting max_iterations
which defaults to a larger value has the old interpretation.
* Example generation should be significantly faster due to a new faster parameter
selection algorithm. This will mostly show up for simple data types - for complex
ones the parameter selection is almost certainly dominated.
* Simplification has some new heuristics that will tend to cut down on cases
where it could previously take a very long time.
* timeout would previously not have been respected in cases where there were a lot
of duplicate examples. You probably wouldn't have previously noticed this because
max_examples counted duplicates, so this was very hard to hit in a way that mattered.
* A number of internal simplifications to the SearchStrategy API.
* You can now access the current Hypothesis version as hypothesis.__version__.
* A top level function is provided for running the stateful tests without the
TestCase infrastructure.

1.4.0

Not secure
------------------

Codename: What a state.

The *big* feature of this release is the new and slightly experimental
stateful testing API. You can read more about that in :doc:`the
appropriate section <stateful>`.

Two minor features the were driven out in the course of developing this:

* You can now set settings.max_shrinks to limit the number of times
Hypothesis will try to shrink arguments to your test. If this is set to
<= 0 then Hypothesis will not rerun your test and will just raise the
failure directly. Note that due to technical limitations if max_shrinks
is <= 0 then Hypothesis will print *every* example it calls your test
with rather than just the failing one. Note also that I don't consider
settings max_shrinks to zero a sensible way to run your tests and it
should really be considered a debug feature.
* There is a new debug level of verbosity which is even *more* verbose than
verbose. You probably don't want this.

Breakage of semi-public SearchStrategy API:

* It is now a required invariant of SearchStrategy that if u simplifies to
v then it is not the case that strictly_simpler(u, v). i.e. simplifying
should not *increase* the complexity even though it is not required to
decrease it. Enforcing this invariant lead to finding some bugs where
simplifying of integers, floats and sets was suboptimal.
* Integers in basic data are now required to fit into 64 bits. As a result
python integer types are now serialized as strings, and some types have
stopped using quite so needlessly large random seeds.

Hypothesis Stateful testing was then turned upon Hypothesis itself, which lead
to an amazing number of minor bugs being found in Hypothesis itself.

Bugs fixed (most but not all from the result of stateful testing) include:

* Serialization of streaming examples was flaky in a way that you would
probably never notice: If you generate a template, simplify it, serialize
it, deserialize it, serialize it again and then deserialize it you would
get the original stream instead of the simplified one.
* If you reduced max_examples below the number of examples already saved in
the database, you would have got a ValueError. Additionally, if you had
more than max_examples in the database all of them would have been
considered.
* given will no longer count duplicate examples (which it never called
your function with) towards max_examples. This may result in your tests
running slower, but that's probably just because they're trying more
examples.
* General improvements to example search which should result in better
performance and higher quality examples. In particular parameters which
have a history of producing useless results will be more aggressively
culled. This is useful both because it decreases the chance of useless
examples and also because it's much faster to not check parameters which
we were unlikely to ever pick!
* integers_from and lists of types with only one value (e.g. [None]) would
previously have had a very high duplication rate so you were probably
only getting a handful of examples. They now have a much lower
duplication rate, as well as the improvements to search making this
less of a problem in the first place.
* You would sometimes see simplification taking significantly longer than
your defined timeout. This would happen because timeout was only being
checked after each *successful* simplification, so if Hypothesis was
spending a lot of time unsuccessfully simplifying things it wouldn't
stop in time. The timeout is now applied for unsuccessful simplifications
too.
* In Python 2.7, integers_from strategies would have failed during
simplification with an OverflowError if their starting point was at or
near to the maximum size of a 64-bit integer.
* flatmap and map would have failed if called with a function without a
__name__ attribute.
* If max_examples was less than min_satisfying_examples this would always
error. Now min_satisfying_examples is capped to max_examples. Note that
if you have assumptions to satisfy here this will still cause an error.

Some minor quality improvements:

* Lists of streams, flatmapped strategies and basic strategies should now
now have slightly better simplification.

1.3.0

Not secure
------------------

New features:

* New verbosity level API for printing intermediate results and exceptions.
* New specifier for strings generated from a specified alphabet.
* Better error messages for tests that are failing because of a lack of enough
examples.

Bug fixes:

* Fix error where use of ForkingTestCase would sometimes result in too many
open files.
* Fix error where saving a failing example that used flatmap could error.
* Implement simplification for sampled_from, which apparently never supported
it previously. Oops.


General improvements:

* Better range of examples when using one_of or sampled_from.
* Fix some pathological performance issues when simplifying lists of complex
values.
* Fix some pathological performance issues when simplifying examples that
require unicode strings with high codepoints.
* Random will now simplify to more readable examples.

1.2.1

Not secure
------------------

A small patch release for a bug in the new executors feature. Tests which require
doing something to their result in order to fail would have instead reported as
flaky.

Page 189 of 195

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.