Show More
@@ -1593,16 +1593,16 b' def _format_time(timespan, precision=3):' | |||
|
1593 | 1593 | return " ".join(time) |
|
1594 | 1594 | |
|
1595 | 1595 | |
|
1596 |
# Unfortunately |
|
|
1596 | # Unfortunately characters outside of range(128) can cause problems in | |
|
1597 | 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 = [ |
|
|
1602 |
if hasattr(sys.stdout, |
|
|
1601 | units = ["s", "ms", "us", "ns"] # the safe value | |
|
1602 | if hasattr(sys.stdout, "encoding") and sys.stdout.encoding: | |
|
1603 | 1603 | try: |
|
1604 |
|
|
|
1605 |
units = [ |
|
|
1604 | "μ".encode(sys.stdout.encoding) | |
|
1605 | units = ["s", "ms", "μs", "ns"] | |
|
1606 | 1606 | except: |
|
1607 | 1607 | pass |
|
1608 | 1608 | scaling = [1, 1e3, 1e6, 1e9] |
@@ -530,6 +530,14 b' def test_time_local_ns():' | |||
|
530 | 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 | 541 | # Test %%capture magic. Added to test issue #13926 |
|
534 | 542 | def test_capture(): |
|
535 | 543 | ip = get_ipython() |
General Comments 0
You need to be logged in to leave comments.
Login now