Skip to Content
Clean Code in Python
book

Clean Code in Python

by Mariano Anaya
August 2018
Intermediate to advanced
332 pages
9h 12m
English
Packt Publishing
Content preview from Clean Code in Python

Basic test cases with pytest

The conditions we tested in the previous section can be rewritten in simple functions with pytest.

Some examples with simple assertions are as follows:

def test_simple_rejected():    merge_request = MergeRequest()    merge_request.downvote("maintainer")    assert merge_request.status == MergeRequestStatus.REJECTEDdef test_just_created_is_pending():    assert MergeRequest().status == MergeRequestStatus.PENDINGdef test_pending_awaiting_review():    merge_request = MergeRequest()    merge_request.upvote("core-dev")    assert merge_request.status == MergeRequestStatus.PENDING

Boolean equality comparisons don't require more than a simple assert statement, whereas other kinds of checks like the ones for the exceptions do require that we ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Clean Code in Python - Second Edition

Clean Code in Python - Second Edition

Mariano Anaya
Python for Programmers

Python for Programmers

Paul Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781788835831Supplemental Content