This lesson is part of the Network Testing with Pytest course.
In this lesson, you will learn:
- The basics of building a Pytest test.
- About Python Assert.
- How to build a basic test in Pytest.
- How to run a test in Pytest.
- About Pytests test discovery.
You can find the scripts and code for this lesson within the Pytest repo under the directory: 002_getting_started/001_creating_first_test.
Creating Your First Test
Tests within Pytest are based upon using the
assert is a built-in keyword within Python that allows us to:
test if a condition in our code returns
If the condition after the
assert does not return
True, then an
AssertionError exception will be raised (example shown below):
>>> assert 1 == 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> AssertionError >>> assert 1 == 1 >>>