# Path: metakernel/tests/utils.py
# def get_kernel(kernel_class=MetaKernel):
#     context = zmq.Context.instance()
#     iopub_socket = context.socket(zmq.PUB)
# 
#     kernel = kernel_class(session=ss.Session(), iopub_socket=iopub_socket,
#                           log=get_log())
#     return kernel
# 
# def get_log_text(obj):
#     """Get the log text from a kernel or a log object."""
#     if isinstance(obj, MetaKernel):
#         log = obj.log
#     else:
#         log = obj
#     return log.handlers[0].stream.getvalue()
# 
# def clear_log_text(obj):
#     """Clear the log text from a kernel or a log object."""
#     if isinstance(obj, MetaKernel):
#         log = obj.log
#     else:
#         log = obj
#     log.handlers[0].stream.truncate(0)
#     log.handlers[0].stream.seek(0)


import os
from metakernel.tests.utils import (get_kernel, get_log_text,
                                    clear_log_text)



def test_ls_magic():
    kernel = get_kernel()
    kernel.do_execute("%ls /tmp")
    text = get_log_text(kernel)
    ## FIXME: failing on Travis
    #assert '/tmp/' in text, text[:100]
    clear_log_text(kernel)

    kernel.do_execute("%ls /tmp --recursive")
    text = get_log_text(kernel)
    ## FIXME: failing on Travis
    #assert '/tmp' in text, text[:100]

# Path: metakernel/tests/utils.py
# def get_kernel(kernel_class=MetaKernel):
#     context = zmq.Context.instance()
#     iopub_socket = context.socket(zmq.PUB)
# 
#     kernel = kernel_class(session=ss.Session(), iopub_socket=iopub_socket,
#                           log=get_log())
#     return kernel
# 
# def get_log_text(obj):
#     """Get the log text from a kernel or a log object."""
#     if isinstance(obj, MetaKernel):
#         log = obj.log
#     else:
#         log = obj
#     return log.handlers[0].stream.getvalue()
# 
# def clear_log_text(obj):
#     """Clear the log text from a kernel or a log object."""
#     if isinstance(obj, MetaKernel):
#         log = obj.log
#     else:
#         log = obj
#     log.handlers[0].stream.truncate(0)
#     log.handlers[0].stream.seek(0)


# Path: metakernel/magics/tests/test_ls_magic.py
import os
from metakernel.tests.utils import (get_kernel, get_log_text,
                                    clear_log_text)




def test_ls_magic():
    kernel = get_kernel()
    kernel.do_execute("%ls /tmp")
    text = get_log_text(kernel)
    ## FIXME: failing on Travis
    #assert '/tmp/' in text, text[:100]
    clear_log_text(kernel)

    kernel.do_execute("%ls /tmp --recursive")
    text = get_log_text(kernel)
    ## FIXME: failing on Travis
    #assert '/tmp' in text, text[:100]

    clear_log_text(kernel)