Ejemplo n.º 1
0
 def test_append(self):
     space = Space('hello world')
     space.append('foo', 'bar')
     space.set('foo2', 'bar')
     space.append('foo', 'two')
     self.assertEqual(space.get('foo'), 'bar')
     self.assertEqual(space.length(), 4)
Ejemplo n.º 2
0
 def testClearWithSpaceArgument(self):
     space = Space("Hellow world")
     space.clear("hey there")
     self.assertEqual(space.length(), 1)
     self.assertEqual(space.get('hey'), 'there', 'Clear with a Space argument should deep copy the argument Space')
Ejemplo n.º 3
0
 def testClear(self):
     space = Space('Hello world')
     self.assertEqual(space.length(), 1)
     self.assertTrue(isinstance(space.clear(), Space), 'clear returns Space so chainable')
     self.assertEqual(space.length(), 0)
Ejemplo n.º 4
0
 def testLength(self):
     space = Space('list\nsingle value')
     self.assertEqual(space.length(), 2, 'space should have 2 names')  # 'name' here means 'key'
     self.assertTrue(isinstance(space.get('list'), Space), 'name without a trailing space should be name')
Ejemplo n.º 5
0
 def testIndexOf(self):
     space = Space("Hello World")
     self.assertEqual(space.length(), 1)
     self.assertEqual(space.indexOf('Hello'), 0, 'indexOf should be correct')