Mercurial > p > roundup > code
comparison test/mocknull.py @ 2532:24d3b25a9157
*** empty log message ***
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sat, 03 Jul 2004 22:40:27 +0000 |
| parents | |
| children | 79fd8537ae3b |
comparison
equal
deleted
inserted
replaced
| 2531:f8c6a09ef485 | 2532:24d3b25a9157 |
|---|---|
| 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) |
