Skip to content

Instantly share code, notes, and snippets.

default_bar_format = '{desc}{percentage:3.0f}%|{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]'
red_bar_format = '{desc}{percentage:3.0f}%|\033[91m{bar}\033[00m| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]'
@chfw
chfw / gist:4ab8b8f74a1b41d4555f
Created January 25, 2016 17:12
how to mock a global variable in a python file
@patch("module.file.BASE_PATH", 'tests/fixtures')
def test_organisation_to_es_document():
# do the test normally
@chfw
chfw / gist:ce131c95da283ede3256
Created December 16, 2015 16:46
How to mock django model's delete method
def do_it(token, logger):
try:
tm = AMODEL.objects.get(unique_id=token)
tm.delete()
except Exception as e:
logger.error("...")
class FakeLogger:
def __init__(self):