Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mission-liao committed Nov 29, 2014
1 parent b9af3bd commit e3ab822
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pyswagger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ def resolve(self, ts):
return obj

def merge(self, other):
""" merge properties from other object
""" merge properties from other object,
only merge from 'not None' to 'None'.
"""
for name, _ in self.__swagger_fields__:
v = getattr(other, name)
if v and getattr(self, name) == None:
if v != None and getattr(self, name) == None:
if isinstance(v, weakref.ProxyTypes):
# TODO: test case
self.update_field(name, v)
Expand Down
3 changes: 2 additions & 1 deletion pyswagger/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ def test_merge(self):

self.assertTrue(len(o2.a), 1)
self.assertEqual(o2.d, None)
self.assertEqual(o2.f, None)

o2.merge(o1)
self.assertTrue(len(o2.a), 1)
self.assertEqaul(o2.f, '')
self.assertEqual(o2.f, '')
self.assertTrue(isinstance(o2.d, ChildObj))
self.assertTrue(isinstance(o2.d, weakref.ProxyTypes))

0 comments on commit e3ab822

Please sign in to comment.