(self)
| 1260 | class TestMisc(TestCase): |
| 1261 | |
| 1262 | def test_decistmt(self): |
| 1263 | # Substitute Decimals for floats in a string of statements. |
| 1264 | # This is an example from the docs. |
| 1265 | |
| 1266 | from decimal import Decimal |
| 1267 | s = '+21.3e-5*-.1234/81.7' |
| 1268 | self.assertEqual(decistmt(s), |
| 1269 | "+Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7')") |
| 1270 | |
| 1271 | # The format of the exponent is inherited from the platform C library. |
| 1272 | # Known cases are "e-007" (Windows) and "e-07" (not Windows). Since |
| 1273 | # we're only showing 11 digits, and the 12th isn't close to 5, the |
| 1274 | # rest of the output should be platform-independent. |
| 1275 | self.assertRegex(repr(eval(s)), '-3.2171603427[0-9]*e-0+7') |
| 1276 | |
| 1277 | # Output from calculations with Decimal should be identical across all |
| 1278 | # platforms. |
| 1279 | self.assertEqual(eval(decistmt(s)), |
| 1280 | Decimal('-3.217160342717258261933904529E-7')) |
| 1281 | |
| 1282 | def test___all__(self): |
| 1283 | expected = token.__all__ + [ |
nothing calls this directly
no test coverage detected