Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

forwardable

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forwardable - npm Package Compare versions

Comparing version
0.3.1
to
0.4.0
+24
forwardable/test/test_def_delegators.py
from unittest import TestCase
from forwardable import def_delegators
class TestDefDelegators(TestCase):
def test_def_delegators(self):
class Foo(object):
def_delegators("dct", ["keys", "values"])
dct = {'key': 42}
foo = Foo()
self.assertEqual(list(foo.keys()), ['key'])
self.assertEqual(list(foo.values()), [42])
def test_attr_splitting(self):
class Foo(object):
def_delegators("dct", "keys, values")
dct = {'key': 42}
foo = Foo()
self.assertEqual(list(foo.keys()), ['key'])
self.assertEqual(list(foo.values()), [42])
+5
-0

@@ -0,1 +1,6 @@

* 0.4.0
- ``def_delegators`` now accepts string form for 2nd argument.
Just like ``collections.namedtuple`` does.
* 0.3.1

@@ -2,0 +7,0 @@

+2
-2
Metadata-Version: 1.1
Name: forwardable
Version: 0.3.1
Version: 0.4.0
Summary: Forwardable as in Ruby's stdlib

@@ -43,3 +43,3 @@ Home-page: https://github.com/5long/forwardable

class Foo(object):
def_delegators('bar', ('add', '__len__'))
def_delegators('bar', 'add, __len__')

@@ -46,0 +46,0 @@ def __init__(self):

@@ -13,2 +13,3 @@ CHANGELOG.rst

forwardable/test/test_def_delegator.py
forwardable/test/test_def_delegators.py
forwardable/test/test_forwardable.py

@@ -8,3 +8,3 @@ """

class Foo(object):
def_delegators('bar', ('add', '__len__'))
def_delegators('bar', 'add, __len__')

@@ -19,3 +19,3 @@ def __init__(self)

__version__ = '0.3.1'
__version__ = '0.4.0'

@@ -64,4 +64,13 @@ __all__ = ["forwardable", "def_delegator", "def_delegators"]

The ``attrs`` argument can be an iterable of attribute names, or
a comma-and-spaces separated string of attribute names. The following
form works identically:
def_delegators(wrapped, ('foo', 'bar')) # Tuple of attribute names
def_delegators(wrapped, 'foo bar') # Separated by space
def_delegators(wrapped, 'foo, bar') # With optional comma
Must be called in a class scope.
"""
attrs = split_attrs(attrs) if isinstance(attrs, basestring) else attrs
for a in attrs:

@@ -78,2 +87,5 @@ def_delegator(wrapped, a, _call_stack_depth=2)

def split_attrs(attrs):
return attrs.replace(',', ' ').split()
def inject(frame):

@@ -80,0 +92,0 @@ if not is_module_frame(frame):

@@ -22,12 +22,2 @@ from unittest import TestCase

def test_def_delegators(self):
class Foo(object):
def_delegators("dct", ["keys", "values"])
dct = {'key': 42}
foo = Foo()
self.assertEqual(list(foo.keys()), ['key'])
self.assertEqual(list(foo.values()), [42])
def test_called_in_non_class_scope(self):

@@ -34,0 +24,0 @@ with self.assertRaises(NotCalledInClassScope):

Metadata-Version: 1.1
Name: forwardable
Version: 0.3.1
Version: 0.4.0
Summary: Forwardable as in Ruby's stdlib

@@ -43,3 +43,3 @@ Home-page: https://github.com/5long/forwardable

class Foo(object):
def_delegators('bar', ('add', '__len__'))
def_delegators('bar', 'add, __len__')

@@ -46,0 +46,0 @@ def __init__(self):

@@ -35,3 +35,3 @@ Forwardable

class Foo(object):
def_delegators('bar', ('add', '__len__'))
def_delegators('bar', 'add, __len__')

@@ -38,0 +38,0 @@ def __init__(self):