some more replay test fixes

This commit is contained in:
Anthony Scopatz 2015-08-23 17:00:26 -04:00
parent 43bc6d48c2
commit ebeb4bcdc0
2 changed files with 8 additions and 4 deletions

View file

@ -12,7 +12,7 @@ from xonsh.shell import Shell
from xonsh.replay import Replayer
SHELL = Shell()
HISTDIR = os.path.join(os.path.dirname(__file__), 'histories')
def run_replay(re_file):
with swap(builtins, '__xonsh_shell__', SHELL):
@ -27,6 +27,7 @@ def cleanup_replay(hist):
if os.path.isfile(fname):
os.remove(fname)
@contextmanager
def a_replay(re_file):
hist = run_replay(re_file)
@ -35,14 +36,16 @@ def a_replay(re_file):
def test_echo():
f = os.path.join('histories', 'echo.json')
f = os.path.join(HISTDIR, 'echo.json')
with a_replay(f) as hist:
yield assert_equal, 2, len(hist)
def test_reecho():
f = os.path.join('histories', 'echo.json')
f = os.path.join(HISTDIR, 'echo.json')
with a_replay(f) as hist:
yield assert_equal, 2, len(hist)
if __name__ == '__main__':
nose.runmodule()

View file

@ -1,5 +1,6 @@
"""Implements a lazy JSON file class that wraps around json data."""
from __future__ import print_function, unicode_literals
import io
import weakref
from contextlib import contextmanager
from collections import Mapping, Sequence
@ -218,7 +219,7 @@ class LazyJSON(Node):
def close(self):
"""Close the file handle, if appropriate."""
if not self.reopen:
if not self.reopen and isinstance(self._f, io.IOBase):
self._f.close()
@contextmanager