コード例 #1
0
ファイル: test_text_history.py プロジェクト: Xenobyte42/hw3
    def test_action(self):
        h = TextHistory()
        action = InsertAction(pos=0, text='abc', from_version=0, to_version=10)

        self.assertEqual(10, h.action(action))
        self.assertEqual('abc', h.text)
        self.assertEqual(10, h.version)
コード例 #2
0
ファイル: test_text_history.py プロジェクト: Xenobyte42/hw3
    def test_action__bad(self):
        h = TextHistory()
        action = InsertAction(pos=0,
                              text='abc',
                              from_version=10,
                              to_version=10)

        with self.assertRaises(ValueError):
            h.action(action)
コード例 #3
0
 def test_insert_opt(self):
     h = TextHistory()
     h.insert('a' * 10)
     h.insert('x', pos=3)
     h.insert('yz', pos=4)
     self.assertEqual('aaaxyzaaaaaaa', h.text)
     actions = h.get_actions(1)
     self.assertEqual(1, len(actions))
     action = actions[0]
     self.assertIsInstance(action, InsertAction)
     opt_value = InsertAction(3, 'xyz', 1, 3)
     self.assertEqual(action.__dict__, opt_value.__dict__)