예제 #1
0
class TextEditorController(object):
    def __init__(self):
        self.document = Document()

    def open(self, path):
        try:
            self.document.open(path)
        except IOError:
            success = False
        else:
            success = True

        return success, self.document

    def save(self, text, path=None):
        self.document.text = text

        if path is not None:
            self.document.path = path

        try:
            self.document.save()
        except IOError:
            return False
        else:
            return True
예제 #2
0
    def test_open_blank_file(self):
        document = Document()
        text_file = open("test_file", "w")
        text_file.close()
        document.open("test_file")

        self.assertEquals("test_file", document.path)
        self.assertEquals("", document.text)
예제 #3
0
 def test_open_blank_file(self):
     document = Document()
     text_file = open("test_file", "w")
     text_file.close()
     document.open("test_file")
     
     self.assertEquals("test_file", document.path)
     self.assertEquals("", document.text)
예제 #4
0
    def test_open_text_file(self):
        document = Document()
        text_file = open("test_file", "w")
        text_file.write("this is only a test")
        text_file.close()
        document.open("test_file")

        self.assertEquals("test_file", document.path)
        self.assertEquals("this is only a test", document.text)
예제 #5
0
 def test_open_text_file(self):
     document = Document()
     text_file = open("test_file", "w")
     text_file.write("this is only a test")
     text_file.close()
     document.open("test_file")
     
     self.assertEquals("test_file", document.path)
     self.assertEquals("this is only a test", document.text)