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")
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")
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))
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))
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")
def test_should_return_string_by_default(self): self.assertEqual(server.get_source("foo"), "foo")