# Path: pyqi/core/exception.py
# class IncompetentDeveloperError(CommandError):
#     pass
# 
# Path: pyqi/core/interfaces/html/input_handler.py
# def load_file_lines(option_value):
#     """Return a list of strings, one per line in the file.
# 
#     Each line will have leading and trailing whitespace stripped from it.
#     """
#     if not hasattr(option_value, 'read'):
#         raise IncompetentDeveloperError("Input type must be a file object.")
#         
#     return [line.strip() for line in option_value]
# 
# def load_file_contents(option_value):
#     """Return the contents of a file as a single string."""
#     if not hasattr(option_value, 'read'):
#         raise IncompetentDeveloperError("Input type must be a file object.")
#     
#     return option_value.read()


import sys
from unittest import TestCase, main
    from StringIO import StringIO
    from io import StringIO
from pyqi.core.exception import IncompetentDeveloperError
from pyqi.core.interfaces.html.input_handler import (load_file_lines,
        load_file_contents)


class HTMLInputHandlerTests(TestCase):
    def setUp(self):
        self.file_like_object = StringIO()
        #Note the whitespace, this tests strip()
        self.file_like_object.write("This is line 1\n")
        self.file_like_object.write(" This is line 2\n")
        self.file_like_object.write("This is line 3 \n")
        #Place it at the beginning of the file again
        self.file_like_object.seek(0)

    def tearDown(self):
        self.file_like_object.close()

    def test_load_file_lines(self):
        """Correctly returns file lines as a list of strings"""
        # can't load a string, etc...
        self.assertRaises(IncompetentDeveloperError, load_file_lines, 'This is not a file')
        result = load_file_lines(self.file_like_object)
        self.assertEqual(result,
                         ["This is line 1",
                          "This is line 2",
                          "This is line 3"])

    def test_load_file_contents(self):
        """Correctly returns file contents"""
        # can't load a string, etc...
        self.assertRaises(IncompetentDeveloperError, load_file_contents, 'This is not a file')


# Path: pyqi/core/exception.py
# class IncompetentDeveloperError(CommandError):
#     pass
# 
# Path: pyqi/core/interfaces/html/input_handler.py
# def load_file_lines(option_value):
#     """Return a list of strings, one per line in the file.
# 
#     Each line will have leading and trailing whitespace stripped from it.
#     """
#     if not hasattr(option_value, 'read'):
#         raise IncompetentDeveloperError("Input type must be a file object.")
#         
#     return [line.strip() for line in option_value]
# 
# def load_file_contents(option_value):
#     """Return the contents of a file as a single string."""
#     if not hasattr(option_value, 'read'):
#         raise IncompetentDeveloperError("Input type must be a file object.")
#     
#     return option_value.read()


# Path: tests/test_core/test_interfaces/test_html/test_input_handler.py
import sys
from unittest import TestCase, main
    from StringIO import StringIO
    from io import StringIO
from pyqi.core.exception import IncompetentDeveloperError
from pyqi.core.interfaces.html.input_handler import (load_file_lines,
        load_file_contents)



class HTMLInputHandlerTests(TestCase):
    def setUp(self):
        self.file_like_object = StringIO()
        #Note the whitespace, this tests strip()
        self.file_like_object.write("This is line 1\n")
        self.file_like_object.write(" This is line 2\n")
        self.file_like_object.write("This is line 3 \n")
        #Place it at the beginning of the file again
        self.file_like_object.seek(0)

    def tearDown(self):
        self.file_like_object.close()

    def test_load_file_lines(self):
        """Correctly returns file lines as a list of strings"""
        # can't load a string, etc...
        self.assertRaises(IncompetentDeveloperError, load_file_lines, 'This is not a file')
        result = load_file_lines(self.file_like_object)
        self.assertEqual(result,
                         ["This is line 1",
                          "This is line 2",
                          "This is line 3"])

    def test_load_file_contents(self):
        """Correctly returns file contents"""
        # can't load a string, etc...
        self.assertRaises(IncompetentDeveloperError, load_file_contents, 'This is not a file')


        result = load_file_contents(self.file_like_object)