test various values for float_precision.
()
| 64 | f = PlainTextFormatter() |
| 65 | |
| 66 | def test_precision(): |
| 67 | """test various values for float_precision.""" |
| 68 | f = PlainTextFormatter() |
| 69 | nt.assert_equal(f(pi), repr(pi)) |
| 70 | f.float_precision = 0 |
| 71 | if numpy: |
| 72 | po = numpy.get_printoptions() |
| 73 | nt.assert_equal(po['precision'], 0) |
| 74 | nt.assert_equal(f(pi), '3') |
| 75 | f.float_precision = 2 |
| 76 | if numpy: |
| 77 | po = numpy.get_printoptions() |
| 78 | nt.assert_equal(po['precision'], 2) |
| 79 | nt.assert_equal(f(pi), '3.14') |
| 80 | f.float_precision = '%g' |
| 81 | if numpy: |
| 82 | po = numpy.get_printoptions() |
| 83 | nt.assert_equal(po['precision'], 2) |
| 84 | nt.assert_equal(f(pi), '3.14159') |
| 85 | f.float_precision = '%e' |
| 86 | nt.assert_equal(f(pi), '3.141593e+00') |
| 87 | f.float_precision = '' |
| 88 | if numpy: |
| 89 | po = numpy.get_printoptions() |
| 90 | nt.assert_equal(po['precision'], 8) |
| 91 | nt.assert_equal(f(pi), repr(pi)) |
| 92 | |
| 93 | def test_bad_precision(): |
| 94 | """test various invalid values for float_precision.""" |
nothing calls this directly
no test coverage detected