• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / zope.interface / 16098775349

04 Mar 2025 10:16PM UTC coverage: 99.073% (+0.05%) from 99.022%
16098775349

push

github

web-flow
Merge pull request #338 from zopefoundation/config-with-c-code-template-3c1c588c

Apply latest meta templates, drop support for Python 3.8

2436 of 2464 branches covered (98.86%)

Branch coverage included in aggregate %.

12209 of 12318 relevant lines covered (99.12%)

6.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/zope/interface/common/tests/basemapping.py
1
##############################################################################
2
#
3
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14
"""Base Mapping tests
×
15
"""
16
from operator import __getitem__
×
17

18

19
def testIReadMapping(self, inst, state, absent):
×
20
    for key in state:
×
21
        self.assertEqual(inst[key], state[key])
×
22
        self.assertEqual(inst.get(key, None), state[key])
×
23
        self.assertIn(key, inst)
×
24

25
    for key in absent:
×
26
        self.assertEqual(inst.get(key, None), None)
×
27
        self.assertEqual(inst.get(key), None)
×
28
        self.assertEqual(inst.get(key, self), self)
×
29
        self.assertRaises(KeyError, __getitem__, inst, key)
×
30

31

32
def test_keys(self, inst, state):
×
33
    # Return the keys of the mapping object
34
    inst_keys = sorted(inst.keys())
×
35
    state_keys = sorted(state.keys())
×
36
    self.assertEqual(inst_keys, state_keys)
×
37

38

39
def test_iter(self, inst, state):
×
40
    # Return the keys of the mapping object
41
    inst_keys = sorted(inst)
×
42
    state_keys = sorted(state.keys())
×
43
    self.assertEqual(inst_keys, state_keys)
×
44

45

46
def test_values(self, inst, state):
×
47
    # Return the values of the mapping object
48
    inst_values = sorted(inst.values())
×
49
    state_values = sorted(state.values())
×
50
    self.assertEqual(inst_values, state_values)
×
51

52

53
def test_items(self, inst, state):
×
54
    # Return the items of the mapping object
55
    inst_items = sorted(inst.items())
×
56
    state_items = sorted(state.items())
×
57
    self.assertEqual(inst_items, state_items)
×
58

59

60
def test___len__(self, inst, state):
×
61
    # Return the number of items
62
    self.assertEqual(len(inst), len(state))
×
63

64

65
def testIEnumerableMapping(self, inst, state):
×
66
    test_keys(self, inst, state)
×
67
    test_items(self, inst, state)
×
68
    test_values(self, inst, state)
×
69
    test___len__(self, inst, state)
×
70

71

72
class BaseTestIReadMapping:
×
73

74
    def testIReadMapping(self):
×
75
        inst = self._IReadMapping__sample()
×
76
        state = self._IReadMapping__stateDict()
×
77
        absent = self._IReadMapping__absentKeys()
×
78
        testIReadMapping(self, inst, state, absent)
×
79

80

81
class BaseTestIEnumerableMapping(BaseTestIReadMapping):
×
82
    # Mapping objects whose items can be enumerated
83

84
    def test_keys(self):
×
85
        # Return the keys of the mapping object
86
        inst = self._IEnumerableMapping__sample()
×
87
        state = self._IEnumerableMapping__stateDict()
×
88
        test_keys(self, inst, state)
×
89

90
    def test_values(self):
×
91
        # Return the values of the mapping object
92
        inst = self._IEnumerableMapping__sample()
×
93
        state = self._IEnumerableMapping__stateDict()
×
94
        test_values(self, inst, state)
×
95

96
    def test_items(self):
×
97
        # Return the items of the mapping object
98
        inst = self._IEnumerableMapping__sample()
×
99
        state = self._IEnumerableMapping__stateDict()
×
100
        test_items(self, inst, state)
×
101

102
    def test___len__(self):
×
103
        # Return the number of items
104
        inst = self._IEnumerableMapping__sample()
×
105
        state = self._IEnumerableMapping__stateDict()
×
106
        test___len__(self, inst, state)
×
107

108
    def _IReadMapping__stateDict(self):
×
109
        return self._IEnumerableMapping__stateDict()
×
110

111
    def _IReadMapping__sample(self):
×
112
        return self._IEnumerableMapping__sample()
×
113

114
    def _IReadMapping__absentKeys(self):
×
115
        return self._IEnumerableMapping__absentKeys()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc