コード例 #1
0
ファイル: texteditor.py プロジェクト: evillair/TextFlow
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_text_save_file(self):
        document = Document()
        document.text = "this is only a test of save file"
        document.path = "test_file"

        document.save()

        text_file = open(document.path, "r")
        self.assertEquals(document.text, text_file.read())
コード例 #3
0
    def test_save_inexistent_file(self):
        document = Document()
        document.text = "this is only a test of save file"
        document.path = "test_file"

        document.save()

        self.assertTrue(os.path.exists(document.path))
        self.assertEquals("this is only a test of save file", document.text)
コード例 #4
0
ファイル: documentmodel.py プロジェクト: akanea/TextFlow
 def test_text_save_file(self):
     document = Document()
     document.text = "this is only a test of save file"
     document.path = "test_file"
     
     document.save()
     
     text_file = open(document.path, "r")
     self.assertEquals(document.text, text_file.read())
コード例 #5
0
ファイル: documentmodel.py プロジェクト: akanea/TextFlow
 def test_save_inexistent_file(self):
     document = Document()
     document.text = "this is only a test of save file"
     document.path = "test_file"
     
     document.save()
     
     self.assertTrue(os.path.exists(document.path))
     self.assertEquals("this is only a test of save file", document.text)
コード例 #6
0
    def test_replace_text_save_file(self):
        text_file = open("test_file", "w")
        text_file.write("this is only a test file")
        text_file.close()

        document = Document()
        document.text = "I changed the text"
        document.path = "test_file"

        document.save()

        text_file = open("test_file", "r")
        self.assertEquals(document.text, text_file.read())
コード例 #7
0
ファイル: documentmodel.py プロジェクト: akanea/TextFlow
 def test_replace_text_save_file(self):
     text_file = open("test_file", "w")
     text_file.write("this is only a test file")
     text_file.close()
     
     document = Document()
     document.text = "I changed the text"
     document.path = "test_file"
     
     document.save()
     
     text_file = open ("test_file", "r")
     self.assertEquals(document.text, text_file.read())