Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Jul 24, 2024
1 parent 65c2732 commit 97c9499
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/pytest-fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
* In generally we call [test fixture](https://en.wikipedia.org/wiki/Test_fixture) the environment in which a test is expected to run.
* Pytest uses the same word for a more generic concept. All the techniques that make it easy to set up the environment and to tear it down after the tests.

General examples:

* Setting up a database server - then removing it to clean the machine.
* Maybe filling the database server with some data - emptying the database.

Specific examples:

* If I'd like to test the login mechanism, I need that before the test starts running we'll have a verified account in the system.
* If I test the 3rd element in a pipeline I need the results of the 2nd pipeline to get started and after the test runs I need to remove all those files.

## PyTest Fixture setup and teardown xUnit style
{id: pytest-fixture-setup-teardown}
Expand All @@ -16,6 +25,10 @@
{i: setup_module}
{i: teardown_module}

{aside}
There are two mechanism in PyTest to setup and teardown fixtures. One of them is the xUnit-style system that is also available in other languages such as Java and C#.
{/aside}

![](examples/pytest/test_fixture.py)

See next slide for the output.
Expand Down

0 comments on commit 97c9499

Please sign in to comment.