Show More
@@ -1592,17 +1592,17 b' def _format_time(timespan, precision=3):' | |||
|
1592 | 1592 | break |
|
1593 | 1593 | return " ".join(time) |
|
1594 | 1594 | |
|
1595 | ||
|
1596 |
# Unfortunately |
|
|
1597 |
# certain terminals. |
|
|
1595 | ||
|
1596 | # Unfortunately characters outside of range(128) can cause problems in | |
|
1597 | # certain terminals. | |
|
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 sa |
|
|
1601 | units = [u"s", u"ms",u'us',"ns"] # the safe value | |
|
1602 | 1602 | if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding: |
|
1603 | 1603 | try: |
|
1604 |
u' |
|
|
1605 |
units = [u"s", u"ms",u' |
|
|
1604 | u'μ'.encode(sys.stdout.encoding) | |
|
1605 | units = [u"s", u"ms",u'μs',"ns"] | |
|
1606 | 1606 | except: |
|
1607 | 1607 | pass |
|
1608 | 1608 | scaling = [1, 1e3, 1e6, 1e9] |
@@ -529,6 +529,12 b' def test_time_local_ns():' | |||
|
529 | 529 | assert ip.user_ns["myvar"] == 1 |
|
530 | 530 | del ip.user_ns["myvar"] |
|
531 | 531 | |
|
532 | def test_time_microseconds_display(): | |
|
533 | """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' | |
|
532 | 538 | |
|
533 | 539 | # Test %%capture magic. Added to test issue #13926 |
|
534 | 540 | def test_capture(): |
General Comments 0
You need to be logged in to leave comments.
Login now