From 7af9566342f3f4d8b7762d5e999368009fbf4483 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 29 Oct 2019 22:19:51 +0000 Subject: [PATCH] Clearing up some stuff in the README about fixture injection --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a1973404..261a9e58 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,12 @@ def _(cities=city_list): expect("Glasgow").contained_in(cities) ``` -The fixture will be executed each time it gets injected into a test. +Fixtures can be injected into each other, using the same syntax. + +The fixture will be executed exactly once each time a test depends on it. + +More specifically, if a fixture F is required by multiple other fixtures that are all injected into a single +test, then F will only be resolved once. Fixtures are great for extracting common setup code that you'd otherwise need to repeat at the top of your tests, but they can also execute teardown code: @@ -105,7 +110,8 @@ def _(db=database): expect(users).contains("Bob") ``` -The code below the `yield` statement in a fixture will be executed after the test runs. +The code below the `yield` statement in a fixture will be executed after the test that depends on it completes, +regardless of the result of the test. ### Descriptive testing