##// END OF EJS Templates
Display Greek small letter mu (#14426)...
M Bussonnier -
r28758:810faec9 merge
parent child Browse files
Show More
@@ -1592,17 +1592,17 b' def _format_time(timespan, precision=3):'
1592 break
1592 break
1593 return " ".join(time)
1593 return " ".join(time)
1594
1594
1595
1595
1596 # Unfortunately the unicode 'micro' symbol can cause problems in
1596 # Unfortunately characters outside of range(128) can cause problems in
1597 # certain terminals.
1597 # certain terminals.
1598 # See bug: https://bugs.launchpad.net/ipython/+bug/348466
1598 # See bug: https://bugs.launchpad.net/ipython/+bug/348466
1599 # Try to prevent crashes by being more secure than it needs to
1599 # Try to prevent crashes by being more secure than it needs to
1600 # E.g. eclipse is able to print a µ, but has no sys.stdout.encoding set.
1600 # E.g. eclipse is able to print a µ, but has no sys.stdout.encoding set.
1601 units = [u"s", u"ms",u'us',"ns"] # the save value
1601 units = ["s", "ms", "us", "ns"] # the safe value
1602 if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding:
1602 if hasattr(sys.stdout, "encoding") and sys.stdout.encoding:
1603 try:
1603 try:
1604 u'\xb5'.encode(sys.stdout.encoding)
1604 "μ".encode(sys.stdout.encoding)
1605 units = [u"s", u"ms",u'\xb5s',"ns"]
1605 units = ["s", "ms", "μs", "ns"]
1606 except:
1606 except:
1607 pass
1607 pass
1608 scaling = [1, 1e3, 1e6, 1e9]
1608 scaling = [1, 1e3, 1e6, 1e9]
@@ -530,6 +530,14 b' def test_time_local_ns():'
530 del ip.user_ns["myvar"]
530 del ip.user_ns["myvar"]
531
531
532
532
533 def test_time_microseconds_display():
534 """Ensure ASCII is used when necessary"""
535 with mock.patch("sys.stdout", io.TextIOWrapper(StringIO(), encoding="utf-8")):
536 assert execution._format_time(0.000001) == "1 \u03bcs"
537 with mock.patch("sys.stdout", io.TextIOWrapper(StringIO(), encoding="ascii")):
538 assert execution._format_time(0.000001) == "1 us"
539
540
533 # Test %%capture magic. Added to test issue #13926
541 # Test %%capture magic. Added to test issue #13926
534 def test_capture():
542 def test_capture():
535 ip = get_ipython()
543 ip = get_ipython()
General Comments 0
You need to be logged in to leave comments. Login now