##// END OF EJS Templates
Darker
Christopher Covington -
Show More
@@ -1598,11 +1598,11 b' def _format_time(timespan, precision=3):'
1598 1598 # See bug: https://bugs.launchpad.net/ipython/+bug/348466
1599 1599 # Try to prevent crashes by being more secure than it needs to
1600 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 safe value
1602 if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding:
1601 units = ["s", "ms", "us", "ns"] # the safe value
1602 if hasattr(sys.stdout, "encoding") and sys.stdout.encoding:
1603 1603 try:
1604 u'μ'.encode(sys.stdout.encoding)
1605 units = [u"s", u"ms",u'μs',"ns"]
1604 "μ".encode(sys.stdout.encoding)
1605 units = ["s", "ms", "μs", "ns"]
1606 1606 except:
1607 1607 pass
1608 1608 scaling = [1, 1e3, 1e6, 1e9]
@@ -529,12 +529,14 b' def test_time_local_ns():'
529 529 assert ip.user_ns["myvar"] == 1
530 530 del ip.user_ns["myvar"]
531 531
532
532 533 def test_time_microseconds_display():
533 534 """Ensure ASCII is used when necessary"""
534 with mock.patch('sys.stdout', io.TextIOWrapper(StringIO(), encoding='utf-8')):
535 assert execution._format_time(0.000001) == '1 \u03bcs'
536 with mock.patch('sys.stdout', io.TextIOWrapper(StringIO(), encoding='ascii')):
537 assert execution._format_time(0.000001) == '1 us'
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
538 540
539 541 # Test %%capture magic. Added to test issue #13926
540 542 def test_capture():
General Comments 0
You need to be logged in to leave comments. Login now