Skip to content

Instantly share code, notes, and snippets.

View carljm's full-sized avatar

Carl Meyer carljm

View GitHub Profile
It seems to me that there's a remarkable level of consensus developing here (though it may not look like it), and a small set of remaining open questions.
The consensus (as I see it):
- Migrate away from scraping external HTML pages, with package owners in control of the migration but a deadline for a forced switch, as outlined in Holger's PEP (with all appropriate caution and testing).
- In some way, migrate to a situation where the popular installer tools install only release files from PyPI by default, but are capable of installing from other locations if the user provides an option.
The open question is basically how to implement the latter portion. I see two options proposed:
import unittest
from unittest import mock
class SomeClass:
def a_method(self):
return 2
class TestStub(unittest.TestCase):
if 'raven.contrib.django' in settings.INSTALLED_APPS: # pragma: no cover
from raven.contrib.celery import register_signal
from raven.contrib.django.models import client
# automatic logging of task failures to Sentry
register_signal(client)
@carljm
carljm / test_something.py
Created February 8, 2013 19:26
writing a py.test fixture that can take params from the test
@pytest.fixture
def template(request):
if 'param' in request.fixturenames:
param = request.getfuncargvalue('param')
else:
param = 'default'
# return something based on param
@carljm
carljm / staticmethod.py
Created June 27, 2012 14:55
pure Python implementation of the staticmethod decorator
class StaticMethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, cls):
return self.func
def staticmethod(func):
@carljm
carljm / conftest.py
Created June 15, 2012 15:11
Using py.test with Django
import os
def pytest_sessionstart(session):
"""
Set up the test environment.
Sets DJANGO_SETTINGS_MODULE and sets up a test database.
[core]
excludesfile = ~/.gitignore
@carljm
carljm / runner.py
Created December 9, 2011 04:07
Unittest2 test discovery and real dotted-path named test selection for Django
"""
An alternative Django ``TEST_RUNNER`` which uses unittest2 test discovery from
a base path specified in settings, rather than requiring all tests to be in
``tests`` module of an app.
If you just run ``./manage.py test``, it'll discover and run all tests
underneath the ``TEST_DISCOVERY_ROOT`` setting (a path). If you run
``./manage.py test full.dotted.path.to.test_module``, it'll run the tests in
that module (you can also pass multiple modules).
@carljm
carljm / tutorial.mkdn
Created August 23, 2011 19:31 — forked from mirisuzanne/tutorial.mkdn
A new Susy tutorial

Susy Tutorial

For this tutorial I'm assuming you are already comfortable with CSS, Sass (I'll use the SCSS syntax) and Compass. Please get set up with each one of those before attempting to use Susy. Sass and Compass both have their own setup instructions and tutorials that you can use.

There is also reference documentation in the works.

What Susy Does

CSS Systems

@carljm
carljm / postactivate
Created July 12, 2011 18:21
Yo dawg, I heard you like Ruby...
#!/bin/bash
# This hook is run after every virtualenv is activated.
export OLD_GEM_HOME=$GEM_HOME
export GEM_HOME=$VIRTUAL_ENV/gems/
export GEM_PATH=
export PATH=$VIRTUAL_ENV/gems/bin:$PATH