Exemple #1
0
    def test__str__(self):
        space = Space("hello world")
        self.assertEqual(space.__str__(), 'hello world\n')
        space.set('foo', 'bar')
        self.assertEqual(space.__str__(), 'foo bar\nhello world\n')

        space2 = Space('john\n age 5')
        self.assertEqual(space2.__str__(), 'john\n age 5\n')
        space2.set('multiline', 'hello\nworld')
        self.assertEqual(space2.__str__(), 'john\n age 5\nmultiline hello\n world\n')
        space2.set('other', 'foobar')
        self.assertEqual(space2.__str__(), 'john\n age 5\nmultiline hello\n world\nother foobar\n')
Exemple #2
0
 def test_prepend(self):
     space = Space('hello world')
     space.prepend('first', 'word')
     self.assertEqual(space.__str__(), 'first word\nhello world\n')