Skip to content

Commit 6f5f3a3

Browse files
author
Richard Jones
committed
*** empty log message ***
1 parent 2b5654f commit 6f5f3a3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/mocknull.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
class MockNull:
3+
def __init__(self, **kwargs):
4+
for key, value in kwargs.items():
5+
self.__dict__[key] = value
6+
7+
def __call__(self, *args, **kwargs): return MockNull()
8+
def __getattr__(self, name):
9+
# This allows assignments which assume all intermediate steps are Null
10+
# objects if they don't exist yet.
11+
#
12+
# For example (with just 'client' defined):
13+
#
14+
# client.db.config.TRACKER_WEB = 'BASE/'
15+
self.__dict__[name] = MockNull()
16+
return getattr(self, name)
17+
18+
def __getitem__(self, key): return self
19+
def __nonzero__(self): return 0
20+
def __str__(self): return ''
21+
def __repr__(self): return '<MockNull 0x%x>'%id(self)

0 commit comments

Comments
 (0)