A Hypothesis database, for use in |settings.database|. Hypothesis automatically saves failures to the database set in |settings.database|. The next time the test is run, Hypothesis will replay any failures from the database in |settings.database| for that test (in |Phase.reuse|
| 168 | |
| 169 | |
| 170 | class ExampleDatabase(metaclass=_EDMeta): |
| 171 | """ |
| 172 | A Hypothesis database, for use in |settings.database|. |
| 173 | |
| 174 | Hypothesis automatically saves failures to the database set in |
| 175 | |settings.database|. The next time the test is run, Hypothesis will replay |
| 176 | any failures from the database in |settings.database| for that test (in |
| 177 | |Phase.reuse|). |
| 178 | |
| 179 | The database is best thought of as a cache that you never need to invalidate. |
| 180 | Entries may be transparently dropped when upgrading your Hypothesis version |
| 181 | or changing your test. Do not rely on the database for correctness; to ensure |
| 182 | Hypothesis always tries an input, use |@example|. |
| 183 | |
| 184 | A Hypothesis database is a simple mapping of bytes to sets of bytes. Hypothesis |
| 185 | provides several concrete database subclasses. To write your own database class, |
| 186 | see :doc:`/how-to/custom-database`. |
| 187 | |
| 188 | Change listening |
| 189 | ---------------- |
| 190 | |
| 191 | An optional extension to |ExampleDatabase| is change listening. On databases |
| 192 | which support change listening, calling |ExampleDatabase.add_listener| adds |
| 193 | a function as a change listener, which will be called whenever a value is |
| 194 | added, deleted, or moved inside the database. See |ExampleDatabase.add_listener| |
| 195 | for details. |
| 196 | |
| 197 | All databases in Hypothesis support change listening. Custom database classes |
| 198 | are not required to support change listening, though they will not be compatible |
| 199 | with features that require change listening until they do so. |
| 200 | |
| 201 | .. note:: |
| 202 | |
| 203 | While no Hypothesis features currently require change listening, change |
| 204 | listening is required by `HypoFuzz <https://hypofuzz.com/>`_. |
| 205 | |
| 206 | Database methods |
| 207 | ---------------- |
| 208 | |
| 209 | Required methods: |
| 210 | |
| 211 | * |ExampleDatabase.save| |
| 212 | * |ExampleDatabase.fetch| |
| 213 | * |ExampleDatabase.delete| |
| 214 | |
| 215 | Optional methods: |
| 216 | |
| 217 | * |ExampleDatabase.move| |
| 218 | |
| 219 | Change listening methods: |
| 220 | |
| 221 | * |ExampleDatabase.add_listener| |
| 222 | * |ExampleDatabase.remove_listener| |
| 223 | * |ExampleDatabase.clear_listeners| |
| 224 | * |ExampleDatabase._start_listening| |
| 225 | * |ExampleDatabase._stop_listening| |
| 226 | * |ExampleDatabase._broadcast_change| |
| 227 | """ |
no outgoing calls