mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
catch errors when calling _hist_get
This commit is contained in:
parent
41750045c2
commit
d3793a3f99
3 changed files with 22 additions and 20 deletions
|
@ -1,10 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Tests xonsh tools."""
|
||||
import builtins
|
||||
import datetime as dt
|
||||
import os
|
||||
import pathlib
|
||||
from tempfile import TemporaryDirectory
|
||||
import stat
|
||||
import builtins
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -1123,12 +1124,9 @@ def test_expandvars(inp, exp, xonsh_builtins):
|
|||
assert expandvars(inp) == exp
|
||||
|
||||
|
||||
import time
|
||||
|
||||
|
||||
@pytest.mark.parametrize('inp, exp',[
|
||||
(572392800.0, 572392800.0),
|
||||
|
||||
(dt.datetime(2016, 8, 2, 13, 24), dt.datetime(2016, 8, 2, 13, 24).timestamp()),
|
||||
])
|
||||
def test_ensure_timestamp(inp, exp):
|
||||
obs = ensure_timestamp(inp)
|
||||
|
|
|
@ -453,22 +453,23 @@ def _hist_show(ns, *args, **kwargs):
|
|||
"""Show the requested portion of shell history.
|
||||
Accepts same parameters with `_hist_get`.
|
||||
"""
|
||||
commands = _hist_get(ns.session,
|
||||
slices=ns.slices,
|
||||
start_time=ns.start_time,
|
||||
end_time=ns.end_time,
|
||||
**kwargs)
|
||||
try:
|
||||
if ns.reverse:
|
||||
commands = reversed(list(commands))
|
||||
if not ns.numerate:
|
||||
for c, _, _ in commands:
|
||||
print(c)
|
||||
else:
|
||||
for c, _, i in commands:
|
||||
print('{}: {}'.format(i, c))
|
||||
commands = _hist_get(ns.session,
|
||||
slices=ns.slices,
|
||||
start_time=ns.start_time,
|
||||
end_time=ns.end_time,
|
||||
**kwargs)
|
||||
except ValueError as err:
|
||||
print("history: error: {}".format(err), file=sys.stderr)
|
||||
return
|
||||
if ns.reverse:
|
||||
commands = reversed(list(commands))
|
||||
if not ns.numerate:
|
||||
for c, _, _ in commands:
|
||||
print(c)
|
||||
else:
|
||||
for c, _, i in commands:
|
||||
print('{}: {}'.format(i, c))
|
||||
|
||||
|
||||
# Interface to History
|
||||
|
|
|
@ -1588,6 +1588,9 @@ def iglobpath(s, ignore_case=False, sort_result=None):
|
|||
|
||||
|
||||
def ensure_timestamp(t):
|
||||
t = float(t)
|
||||
try:
|
||||
t = float(t)
|
||||
except TypeError:
|
||||
t = t.timestamp()
|
||||
return t
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue