Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 #!/usr/bin/env python
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 # You can obtain one at http://mozilla.org/MPL/2.0/.
8 import os
9 import tempfile
10 import unittest
12 from mozprofile.profile import Profile
15 class CloneCleanupTest(unittest.TestCase):
16 """
17 test cleanup logic for the clone functionality
18 see https://bugzilla.mozilla.org/show_bug.cgi?id=642843
19 """
21 def setUp(self):
22 # make a profile with one preference
23 path = tempfile.mktemp()
24 self.profile = Profile(path,
25 preferences={'foo': 'bar'},
26 restore=False)
27 user_js = os.path.join(self.profile.profile, 'user.js')
28 self.assertTrue(os.path.exists(user_js))
30 def test_restore_true(self):
31 # make a clone of this profile with restore=True
32 clone = Profile.clone(self.profile.profile, restore=True)
34 clone.cleanup()
36 # clone should be deleted
37 self.assertFalse(os.path.exists(clone.profile))
39 def test_restore_false(self):
40 # make a clone of this profile with restore=False
41 clone = Profile.clone(self.profile.profile, restore=False)
43 clone.cleanup()
45 # clone should still be around on the filesystem
46 self.assertTrue(os.path.exists(clone.profile))
49 if __name__ == '__main__':
50 unittest.main()