Skip to content
Snippets Groups Projects
Commit 2f6508fe authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

tests passing for v2.0.24

parent 6a24aea8
No related branches found
Tags v2.0.24
No related merge requests found
......@@ -3,6 +3,7 @@ import typing
import threading
import inspect
import functools
import six
from ...exceptions import ResourceLocked, ResourceNotLocked
......@@ -70,7 +71,10 @@ class LockedDataset(object):
return super(LockedDataset, self).__setattr__(key, value)
def __call__(self, blocking=True, timeout=-1):
get_internal(self).args = (blocking, timeout)
if six.PY2:
get_internal(self).args = blocking,
else:
get_internal(self).args = blocking, timeout
return self
def __enter__(self):
......
......@@ -6,6 +6,22 @@ logger = logging.getLogger(__name__)
def static_var(var_name, value):
"""
Declare a static variable for given function
Use it like:
@static_var('counter', 2)
def count():
count.counter += 1
or (syntax valid only on Python 3)
class MyClass:
@static_var('counter', 2)
def count():
MyClass.counter += 1
"""
def decorate(func):
setattr(func, var_name, value)
return func
......
import unittest
from threading import Thread
from time import sleep
import six
from six.moves.queue import Queue
from satella.coding import static_var
......@@ -18,6 +18,7 @@ class FunTestTest(unittest.TestCase):
static_fun(3)
self.assertEquals(static_fun.counter, 4)
@unittest.skipIf(six.PY2, 'Syntax unsupported on Python 2')
def test_fun_static_method(self):
class MyClass(object):
@static_var("counter", 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment