コード例 #1
0
ファイル: test_mappings.py プロジェクト: houseofsuns/snakeoil
 def test_iter(self):
     s = set()
     for item in chain(iter(self.orig_dict), iter(self.new_dict)):
         s.add(item)
     for x in mappings.StackedDict(self.orig_dict, self.new_dict):
         self.assertIn(x, s)
         s.remove(x)
     self.assertEqual(len(s), 0)
コード例 #2
0
 def test_iter(self):
     s = set()
     for item in chain(iter(self.orig_dict), iter(self.new_dict)):
         s.add(item)
     for x in mappings.StackedDict(self.orig_dict, self.new_dict):
         assert x in s
         s.remove(x)
     assert len(s) == 0
コード例 #3
0
    def test_stacking(self):
        o = dict(self.orig_dict)
        std = mappings.StackedDict(o, self.new_dict)
        for x in chain(*list(map(iter, (self.orig_dict, self.new_dict)))):
            assert x in std

        for key in list(self.orig_dict.keys()):
            del o[key]
        for x in self.orig_dict:
            assert x not in std
        for x in self.new_dict:
            assert x in std
コード例 #4
0
ファイル: test_mappings.py プロジェクト: houseofsuns/snakeoil
    def test_stacking(self):
        o = dict(self.orig_dict)
        std = mappings.StackedDict(o, self.new_dict)
        for x in chain(*map(iter, (self.orig_dict, self.new_dict))):
            self.assertIn(x, std)

        for key in self.orig_dict.iterkeys():
            del o[key]
        for x in self.orig_dict:
            self.assertNotIn(x, std)
        for x in self.new_dict:
            self.assertIn(x, std)
コード例 #5
0
 def test_keys(self):
     assert sorted(mappings.StackedDict(self.orig_dict, self.new_dict)) == \
         sorted(list(self.orig_dict.keys()) + list(self.new_dict.keys()))
コード例 #6
0
 def test_clear(self):
     pytest.raises(TypeError, mappings.StackedDict().clear)
コード例 #7
0
 def test_delattr(self):
     pytest.raises(TypeError, mappings.StackedDict().__delitem__, (1, 2))
コード例 #8
0
 def test_len(self):
     assert sum(map(len, (self.orig_dict, self.new_dict))) == \
         len(mappings.StackedDict(self.orig_dict, self.new_dict))
コード例 #9
0
 def test_contains(self):
     std = mappings.StackedDict(self.orig_dict, self.new_dict)
     assert 1 in std
コード例 #10
0
ファイル: test_mappings.py プロジェクト: houseofsuns/snakeoil
 def test_keys(self):
     self.assertEqual(
         sorted(mappings.StackedDict(self.orig_dict, self.new_dict)),
         sorted(self.orig_dict.keys() + self.new_dict.keys()))
コード例 #11
0
ファイル: test_mappings.py プロジェクト: houseofsuns/snakeoil
 def test_clear(self):
     self.assertRaises(TypeError, mappings.StackedDict().clear)
コード例 #12
0
ファイル: test_mappings.py プロジェクト: houseofsuns/snakeoil
 def test_delattr(self):
     self.assertRaises(TypeError,
                       mappings.StackedDict().__delitem__, (1, 2))
コード例 #13
0
ファイル: test_mappings.py プロジェクト: houseofsuns/snakeoil
 def test_len(self):
     self.assertEqual(
         sum(map(len, (self.orig_dict, self.new_dict))),
         len(mappings.StackedDict(self.orig_dict, self.new_dict)))
コード例 #14
0
ファイル: test_mappings.py プロジェクト: houseofsuns/snakeoil
 def test_contains(self):
     std = mappings.StackedDict(self.orig_dict, self.new_dict)
     self.assertIn(1, std)
     self.assertTrue(std.has_key(1))