Skip to content

Instantly share code, notes, and snippets.

View pelme's full-sized avatar

Andreas Pelme pelme

  • Personalkollen
  • Linköping, Sweden
View GitHub Profile
# -*- coding: utf-8 -*
from __future__ import print_function, division, absolute_import
import click
import copy
import os
import subprocess
import functools
import dj_database_url
# -*- coding: utf-8 -*
from __future__ import print_function, division, absolute_import, unicode_literals
import hashlib
import inspect
def main():
import django
django.setup()

Keybase proof

I hereby claim:

  • I am pelme on github.
  • I am pelme (https://keybase.io/pelme) on keybase.
  • I have a public key whose fingerprint is 952E B53A E6DB 09C0 E414 76E1 D7F2 54C4 0A16 7777

To claim this, I am signing this object:

@pelme
pelme / gist:5474397
Last active December 16, 2015 17:59
The quiet output does not show test execution times:
$ py.test -m 'not django_db' -q
..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
import pytest
from contextlib import contextmanager
from functools import wraps
# TODO: Make it possible to pass standard pytest.fixture args here too, like scope, params etc..
def pytest_contextfixture(fn):
ctxmgr = contextmanager(fn)
@pytest.fixture
@wraps(fn)
from mock import patch
from contextlib import contextmanager
def _patch_method(obj, method_name, return_value=DEFAULT, **kwargs):
# Allow specifying a dotted string instead of an object
if isinstance(obj, basestring):
return patch('%s.%s' % (obj, method_name), autospec=True, return_value=return_value, **kwargs)
kwargs['autospec'] = True
#!/bin/bash
SOURCE_DIR=$1
TARGET_DIR=$2
SOURCE_DIR_FULL=$(grealpath $SOURCE_DIR)
TARGET_DIR_FULL=$(grealpath $TARGET_DIR)
cd $SOURCE_DIR