示例#1
0
    def test_should_support_utf8(self):
        fd, filename = tempfile.mkstemp(prefix="elpy-test-")
        self.addCleanup(os.remove, filename)
        with open(filename, "wb") as f:
            f.write(u"möp".encode("utf-8"))

        source = server.get_source({'filename': filename})

        self.assertEqual(source, u"möp")
示例#2
0
    def test_should_return_file_contents(self):
        fd, filename = tempfile.mkstemp(prefix="elpy-test-")
        self.addCleanup(os.remove, filename)
        with open(filename, "w") as f:
            f.write("file contents")

        fileobj = {'filename': filename}

        self.assertEqual(server.get_source(fileobj), "file contents")
示例#3
0
    def test_should_clean_up_tempfile(self):
        fd, filename = tempfile.mkstemp(prefix="elpy-test-")
        with open(filename, "w") as f:
            f.write("file contents")

        fileobj = {'filename': filename, 'delete_after_use': True}

        self.assertEqual(server.get_source(fileobj), "file contents")
        self.assertFalse(os.path.exists(filename))
示例#4
0
    def test_should_support_utf8(self):
        fd, filename = tempfile.mkstemp(prefix="elpy-test-")
        self.addCleanup(os.remove, filename)
        with open(filename, "wb") as f:
            f.write(u"möp".encode("utf-8"))

        source = server.get_source({'filename': filename})

        self.assertEqual(source, u"möp")
示例#5
0
    def test_should_clean_up_tempfile(self):
        fd, filename = tempfile.mkstemp(prefix="elpy-test-")
        with open(filename, "w") as f:
            f.write("file contents")

        fileobj = {"filename": filename, "delete_after_use": True}

        self.assertEqual(server.get_source(fileobj), "file contents")
        self.assertFalse(os.path.exists(filename))
示例#6
0
    def test_should_return_file_contents(self):
        fd, filename = tempfile.mkstemp(prefix="elpy-test-")
        self.addCleanup(os.remove, filename)
        with open(filename, "w") as f:
            f.write("file contents")

        fileobj = {"filename": filename}

        self.assertEqual(server.get_source(fileobj), "file contents")
示例#7
0
 def test_should_return_string_by_default(self):
     self.assertEqual(server.get_source("foo"), "foo")
示例#8
0
 def test_should_return_string_by_default(self):
     self.assertEqual(server.get_source("foo"),
                      "foo")