Get rid of dotted_getattr.

This commit is contained in:
Florian Bruhin 2014-11-10 18:59:13 +01:00
parent eaca891616
commit c70f6f534b
2 changed files with 0 additions and 48 deletions

View File

@ -75,41 +75,6 @@ class ReadFileTests(unittest.TestCase):
self.assertEqual(content.splitlines()[0], "Hello World!") self.assertEqual(content.splitlines()[0], "Hello World!")
class DottedGetattrTests(unittest.TestCase):
"""Test dotted_getattr.
Attributes:
test: Test class instance for getattr.
"""
class Test:
"""Sample class used to test dotted_getattr."""
foo = None
class Test2:
"""Sample class used to test dotted_getattr."""
bar = 1
def setUp(self):
self.test = self.Test()
self.test.foo = self.Test2()
def test_dotted_getattr(self):
"""Test dotted_getattr with a valid path."""
attr = utils.dotted_getattr(self, 'test.foo.bar')
self.assertEqual(attr, 1)
def test_invalid_path(self):
"""Test dotted_getattr with an invalid path."""
with self.assertRaises(AttributeError):
_ = utils.dotted_getattr(self, 'test.foo.baz')
class InterpolateColorTests(unittest.TestCase): class InterpolateColorTests(unittest.TestCase):
"""Tests for interpolate_color. """Tests for interpolate_color.

View File

@ -85,19 +85,6 @@ def read_file(filename):
return data.decode('UTF-8') return data.decode('UTF-8')
def dotted_getattr(obj, path):
"""getattr supporting the dot notation.
Args:
obj: The object where to start.
path: A dotted object path as a string.
Return:
The object at path.
"""
return functools.reduce(getattr, path.split('.'), obj)
def pastebin(name, title, text, parent=None): def pastebin(name, title, text, parent=None):
"""Paste the text into a pastebin and return the URL. """Paste the text into a pastebin and return the URL.