Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Clearing up some stuff in the README about fixture injection
Browse files Browse the repository at this point in the history
Darren Burns committed Oct 29, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 88b4ede commit 7af9566
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7af9566

Please sign in to comment.