MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_context_templates

Method test_context_templates

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

Source from the content-addressed store, hash-verified

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