@@ -413,6 +413,27 @@ def test_formatstrformatter():
413413 tmp_form = mticker .StrMethodFormatter ('{x:05d}' )
414414 nose .tools .assert_equal ('00002' , tmp_form (2 ))
415415
416+
417+ def test_EngFormatter_formatting ():
418+ """
419+ Create two instances of EngFormatter with default parameters, with and
420+ without a unit string ('s' for seconds). Test the formatting in some cases,
421+ especially the case when no SI prefix is present, for values in [1, 1000).
422+
423+ Should not raise exceptions.
424+ """
425+ unitless = mticker .EngFormatter ()
426+ nose .tools .assert_equal (unitless (0.1 ), u'100 m' )
427+ nose .tools .assert_equal (unitless (1 ), u'1' )
428+ nose .tools .assert_equal (unitless (999.9 ), u'999.9' )
429+ nose .tools .assert_equal (unitless (1001 ), u'1.001 k' )
430+
431+ with_unit = mticker .EngFormatter (unit = u's' )
432+ nose .tools .assert_equal (with_unit (0.1 ), u'100 ms' )
433+ nose .tools .assert_equal (with_unit (1 ), u'1 s' )
434+ nose .tools .assert_equal (with_unit (999.9 ), u'999.9 s' )
435+ nose .tools .assert_equal (with_unit (1001 ), u'1.001 ks' )
436+
416437if __name__ == '__main__' :
417438 import nose
418439 nose .runmodule (argv = ['-s' , '--with-doctest' ], exit = False )
0 commit comments