This article is now published on my website: Prefer Subshells for Context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
import os | |
import shlex | |
from subprocess import Popen, PIPE | |
def execute_in_virtualenv(virtualenv_name, commands): | |
'''Execute Python code in a virtualenv, return its stdout and stderr.''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from django.test.runner import DiscoverRunner | |
class ParallelTestRunner(DiscoverRunner): | |
""" | |
Uses a combination of hours, minutes and microseconds. This should avoid any db name conflicts and when | |
Django creates the db, the name will abide by the MySQL 16 character limit. | |
""" | |
settings.DATABASES[DEFAULT_DB_ALIAS]['NAME'] = datetime.utcnow().strftime('%H%M%f') |