コード例 #1
0
ファイル: test_mutable.py プロジェクト: xglhjk6/fuel-web
class TestMutableDict(BaseUnitTest):
    def setUp(self):
        self.standard = {'1': 1}
        self.mutable_dict = MutableDict()
        self.mutable_dict.update(self.standard)

    def test_pop_existing(self, m_changed):
        self.assertEqual(self.mutable_dict.pop('1'), self.standard.pop('1'))
        m_changed.assert_called_once_with()

    def test_pop_existing_with_default(self, m_changed):
        self.assertEqual(self.mutable_dict.pop('1', None),
                         self.standard.pop('1', None))
        m_changed.assert_called_once_with()

    def test_pop_not_existing(self, m_changed):
        self.assertRaises(KeyError, self.mutable_dict.pop, '2')
        self.assertFalse(m_changed.called)

    def test_pop_not_existing_with_default(self, m_changed):
        self.assertEqual(self.mutable_dict.pop('2', {}),
                         self.standard.pop('2', {}))
        m_changed.assert_called_once_with()

    def test_popitem(self, m_changed):
        self.assertItemsEqual(self.mutable_dict.popitem(),
                              self.standard.popitem())
        m_changed.assert_called_once_with()

        m_changed.reset_mock()
        self.assertRaises(KeyError, self.mutable_dict.popitem)
        self.assertFalse(m_changed.called)
コード例 #2
0
ファイル: test_mutable.py プロジェクト: vangogh-ken/fuel-web
class TestMutableDict(BaseUnitTest):
    def setUp(self):
        self.standard = {'1': 1}
        self.mutable_dict = MutableDict()
        self.mutable_dict.update(self.standard)

    def test_pop_existing(self, m_changed):
        self.assertEqual(self.mutable_dict.pop('1'), self.standard.pop('1'))
        m_changed.assert_called_once_with()

    def test_pop_existing_with_default(self, m_changed):
        self.assertEqual(self.mutable_dict.pop('1', None),
                         self.standard.pop('1', None))
        m_changed.assert_called_once_with()

    def test_pop_not_existing(self, m_changed):
        self.assertRaises(KeyError, self.mutable_dict.pop, '2')
        self.assertFalse(m_changed.called)

    def test_pop_not_existing_with_default(self, m_changed):
        self.assertEqual(self.mutable_dict.pop('2', {}),
                         self.standard.pop('2', {}))
        m_changed.assert_called_once_with()

    def test_popitem(self, m_changed):
        self.assertItemsEqual(self.mutable_dict.popitem(),
                              self.standard.popitem())
        m_changed.assert_called_once_with()

        m_changed.reset_mock()
        self.assertRaises(KeyError, self.mutable_dict.popitem)
        self.assertFalse(m_changed.called)
コード例 #3
0
ファイル: test_mutable.py プロジェクト: dnikishov/fuel-web
class TestMutableDictBase(TestMutableBase):
    def setUp(self):
        super(TestMutableDictBase, self).setUp()
        self.standard = {'1': 1}
        self.mutable_obj = MutableDict()
        self.mutable_obj.update(self.standard)
コード例 #4
0
ファイル: test_mutable.py プロジェクト: zhanghui9700/fuel-web
class TestMutableDictBase(TestMutableBase):
    def setUp(self):
        super(TestMutableDictBase, self).setUp()
        self.standard = {'1': 1}
        self.mutable_obj = MutableDict()
        self.mutable_obj.update(self.standard)