Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nonexistent_file(self):
self.assertRaises(git_utils.GitError, git_utils.read_file, 'branch',
'nonexist.txt')
def test_read_file(self):
self.assertEqual(git_utils.read_file('branch', 'file.txt'),
b'this is some text')
def test_read_file_as_text(self):
self.assertEqual(git_utils.read_file('branch', 'file.txt',
universal_newlines=True),
'this is some text')
def list_versions(branch='gh-pages'):
try:
return Versions.loads(git_utils.read_file(
branch, versions_file, universal_newlines=True
))
except git_utils.GitError:
return Versions()
def do_GET(self):
path = self.send_headers()
if path is not None:
body = git_utils.read_file(self.branch, path)
self.wfile.write(body)