(self)
| 4154 | """Test the context templates.""" |
| 4155 | |
| 4156 | def test_context_templates(self): |
| 4157 | BasicContext = self.decimal.BasicContext |
| 4158 | ExtendedContext = self.decimal.ExtendedContext |
| 4159 | getcontext = self.decimal.getcontext |
| 4160 | setcontext = self.decimal.setcontext |
| 4161 | InvalidOperation = self.decimal.InvalidOperation |
| 4162 | DivisionByZero = self.decimal.DivisionByZero |
| 4163 | Overflow = self.decimal.Overflow |
| 4164 | Underflow = self.decimal.Underflow |
| 4165 | Clamped = self.decimal.Clamped |
| 4166 | |
| 4167 | assert_signals(self, BasicContext, 'traps', |
| 4168 | [InvalidOperation, DivisionByZero, Overflow, Underflow, Clamped] |
| 4169 | ) |
| 4170 | |
| 4171 | savecontext = getcontext().copy() |
| 4172 | basic_context_prec = BasicContext.prec |
| 4173 | extended_context_prec = ExtendedContext.prec |
| 4174 | |
| 4175 | ex = None |
| 4176 | try: |
| 4177 | BasicContext.prec = ExtendedContext.prec = 441 |
| 4178 | for template in BasicContext, ExtendedContext: |
| 4179 | setcontext(template) |
| 4180 | c = getcontext() |
| 4181 | self.assertIsNot(c, template) |
| 4182 | self.assertEqual(c.prec, 441) |
| 4183 | except Exception as e: |
| 4184 | ex = e.__class__ |
| 4185 | finally: |
| 4186 | BasicContext.prec = basic_context_prec |
| 4187 | ExtendedContext.prec = extended_context_prec |
| 4188 | setcontext(savecontext) |
| 4189 | if ex: |
| 4190 | raise ex |
| 4191 | |
| 4192 | def test_default_context(self): |
| 4193 | DefaultContext = self.decimal.DefaultContext |
nothing calls this directly
no test coverage detected