Created
April 16, 2012 15:30
-
-
Save jpellerin/2399484 to your computer and use it in GitHub Desktop.
totally untested decorator swap plugin
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
## 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