Commit 3c1fc036 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[2710] address review comments

- set 'file used' to None if set to nonexistent file
- remove couple of unnecessary test value checks
- slightly more efficient temporary file write
parent 1090b92f
......@@ -512,7 +512,7 @@ class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
# If the file does not exist, set accounts to empty, and return
if not os.path.exists(accounts_file):
self._user_infos = {}
self.__accounts_file = accounts_file
self.__accounts_file = None
self.__accounts_file_mtime = 0
return
......
......@@ -99,8 +99,7 @@ class TmpTextFile:
def __enter__(self):
with open(self.__path, 'w') as f:
for line in self.__contents:
f.write(line)
f.write("\n".join(self.__contents))
def __exit__(self, type, value, traceback):
os.unlink(self.__path)
......@@ -503,7 +502,6 @@ class TestSecureHTTPServer(unittest.TestCase):
def test_create_user_info_changing_file_time(self):
self.assertEqual(0, len(self.server._user_infos))
self.assertFalse('root' in self.server._user_infos)
# Create a file
accounts_file = BUILD_FILE_PATH + 'new_file.csv'
......@@ -533,7 +531,6 @@ class TestSecureHTTPServer(unittest.TestCase):
Check that the accounts file is re-read if the file name is different
"""
self.assertEqual(0, len(self.server._user_infos))
self.assertFalse('root' in self.server._user_infos)
# Create two files
accounts_file1 = BUILD_FILE_PATH + 'new_file.csv'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment