Skip to content

Lazy assertions postpone the fury when things go wrong.

Notifications You must be signed in to change notification settings

ersincine/lazy-assertions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example usage:

x = 2
y = 2
numbers = []
path = 'abc.png'
this_true((empty(numbers) | equal(x, y)) & exists(path))

Output:

AssertionError: Expected: True   |   Found: False
AND [FALSE]
├── OR [TRUE]
│   ├── empty([]) [TRUE]
│   └── equal(2, 2) [TRUE]
└── exists('abc.png') [FALSE]

Without lazy-assertions one could do:

import os
x = 2
y = 2
numbers = []
path = 'abc.png'
assert((numbers == [] or x == y) and os.path.exists(path))

The problem is the output:

assert((numbers == [] or x == y) and os.path.exists(path))
AssertionError

It is not possible to understand what went wrong. We do not even know what the values of the variables were.

About

Lazy assertions postpone the fury when things go wrong.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages