testing/mozbase/mozprofile/tests/test_clone_cleanup.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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()

mercurial