Our development team uses a PEP8 linter which requires a maximum line length of 80 characters.
When I\'m writing unit tests in python, I like to have
Sort of a context-specific approach to the problem. The test case you've presented actually looks very much like a Natural Language format of describing the necessary steps for a test case to take.
See if using the behave Behavior Driver development style framework would make more sense here. Your "feature" might look like (see how the given
, when
, then
reflect what you had):
Feature: Connect error testing
Scenario: Client event listener receives connection refused error without server
Given server is offline
when client connect starts
then client receives connection refused error
There is also relevant pyspecs package, sample usage from a recent answer on a related topic: