Skip to content

Instantly share code, notes, and snippets.

@jpellerin
Created April 16, 2012 15:30
Show Gist options
  • Save jpellerin/2399484 to your computer and use it in GitHub Desktop.
Save jpellerin/2399484 to your computer and use it in GitHub Desktop.
totally untested decorator swap plugin
## the plugin
from nose.plugins import Plugin
import thedecorators
import thingtwo
class Swapper(Plugin):
enableOpt = 'swap'
def options(self, parser, env):
"""Register commandline options.
"""
parser.add_option('--swap-implementation',
action='store_true',
dest=self.enableOpt,
default=env.get('SWAPS'),
help="Swap thingone for thingtwo")
def begin(self):
# only called if plugin is active
thedecorators._implementation = thingtwo
## inside thedecorators
import thingone
_implementation = thingone
def somedecorator(func):
return _implementation.somedecorator(func)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment