Commits

Jason R. Coombs  committed 35535b0

Renamed test example to make it a bit more fun.

  • Participants
  • Parent commits 262e1a8

Comments (0)

Files changed (1)

File jaraco/json/test_encoding.py

 
 from jaraco.json.main import encode, decode
 
-class MyCollection(object):
+class Satchel(object):
 	"""
-	A list of items, specifically not subclassed from list to demonstrate
+	A collection of items, specifically not subclassed from list to demonstrate
 	a custom collection.
 	"""
 	def __init__(self):
 		self.items = []
 
-	def append(self, item):
+	def add(self, item):
 		self.items.append(item)
 
-class MyItem(object):
-	def __init__(self, value):
-		self.value = value
+class Marble(object):
+	def __init__(self, color):
+		self.color = color
 
 def test_encode_object():
 	"""
 	Serialize an object with nested objects into json.
 	"""
-	coll = MyCollection()
-	coll.append(MyItem(63))
-	coll.append({'a': 'dict'})
-	coll.append((1,2,3))
+	coll = Satchel()
+	coll.add(Marble('blue'))
+	coll.add({'a': 'dict'})
+	coll.add((1,2,3))
 	
 	serialized = encode(coll)
+	# the serialized object better be a bytestring.
 	assert isinstance(serialized, basestring)
 	return serialized
 
 	"""
 	serialized = test_encode_object()
 	coll = decode(serialized)
+	assert isinstance(coll, Satchel)
 	assert len(coll.items) == 3
 	custom, d, t = coll.items
-	assert isinstance(custom, MyItem)
+	assert isinstance(custom, Marble)
 	assert 'a' in d
 	assert t == range(1,4)
-	assert custom.value == 63
+	assert custom.color == 'blue'