mirror of
https://github.com/quantum5/optimize-later.git
synced 2025-04-24 12:32:04 -04:00
No longer ignores reset=True when using optimize_context as decorator.
This commit is contained in:
parent
ab706fb23a
commit
c2ff12a3e9
|
@ -66,6 +66,6 @@ class optimize_context(with_metaclass(NoArgDecoratorMeta)):
|
||||||
def __call__(self, function):
|
def __call__(self, function):
|
||||||
@wraps(function)
|
@wraps(function)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
with optimize_context(self.callbacks):
|
with optimize_context(self.callbacks, reset=self.reset):
|
||||||
return function(*args, **kwargs)
|
return function(*args, **kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
|
@ -27,6 +27,16 @@ class OptimizeContextTest(TestCase):
|
||||||
with optimize_context([3]):
|
with optimize_context([3]):
|
||||||
self.assertEqual(config.get_callbacks(), [1, 2, 3])
|
self.assertEqual(config.get_callbacks(), [1, 2, 3])
|
||||||
|
|
||||||
|
@optimize_context([3], reset=True)
|
||||||
|
def test():
|
||||||
|
self.assertEqual(config.get_callbacks(), [3])
|
||||||
|
test()
|
||||||
|
|
||||||
|
@optimize_context([3])
|
||||||
|
def test():
|
||||||
|
self.assertEqual(config.get_callbacks(), [1, 2, 3])
|
||||||
|
test()
|
||||||
|
|
||||||
self.assertEqual(config.get_callbacks(), [1, 2])
|
self.assertEqual(config.get_callbacks(), [1, 2])
|
||||||
|
|
||||||
config.register_callback(4)
|
config.register_callback(4)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -4,7 +4,7 @@ from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='optimize-later',
|
name='optimize-later',
|
||||||
version='0.1',
|
version='0.1.1',
|
||||||
description='Mark potentially slow blocks for notifications when it actually turns out too slow, '
|
description='Mark potentially slow blocks for notifications when it actually turns out too slow, '
|
||||||
'so you can optimize it.',
|
'so you can optimize it.',
|
||||||
author='Quantum',
|
author='Quantum',
|
||||||
|
|
Loading…
Reference in a new issue