Skip to content

Instantly share code, notes, and snippets.

acdha / gist:f1f506b47a38574f3a5f
Last active Aug 29, 2015
Quick mock example showing how to simulate errors
View gist:f1f506b47a38574f3a5f
>>> from unittest import mock
>>> import json
>>> m_o = mock.mock_open()
>>> m_o.side_effect = OSError('Insufficient voltage')
>>> json.load(m_o('foo.json', 'rb'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/", line 896, in __call__
return _mock_self._mock_call(*args, **kwargs)
File "/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/unittest/", line 952, in _mock_call
kennethreitz /
Created Jun 9, 2012
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
charliepark / hatchshow.js
Created Jul 30, 2011
A jquery typography plugin.
View hatchshow.js
<script type="text/javascript" src=""></script>
<script type="text/javascript" charset="utf-8">
jQuery.fn.hatchShow = function(){
var t = $(this);
t.wrap("<span class='hatchshow_temp' style='display:block'>");
var pw = t.parent().width();