Testing behavior with unittest
The standard-library unittest framework organizes tests into test cases and assertions. A test should describe a behavior that must remain correct as the application changes.
Cover boundaries and failures
Testing only a successful example gives weak confidence. Test normal values, boundaries, invalid input and important exception paths.
Keep unit tests isolated
A unit test should not depend on a live network, current clock time or shared database unless that dependency is intentionally controlled. Isolation makes the test suite fast and repeatable.
Practice: write tests for a discount function covering a normal discount, zero discount, maximum discount and invalid input.