MCPcopy Index your code
hub / github.com/python/cpython / test_context_templates

Method test_context_templates

Lib/test/test_decimal.py:4156–4190  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

assert_signalsFunction · 0.85
getcontextFunction · 0.85
setcontextFunction · 0.85
assertIsNotMethod · 0.80
copyMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected