testing/mozbase/mozprofile/tests/bug758250.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
-rwxr-xr-x

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 import mozprofile
     4 import os
     5 import shutil
     6 import tempfile
     7 import unittest
    10 here = os.path.dirname(os.path.abspath(__file__))
    13 class Bug758250(unittest.TestCase):
    14     """
    15     use of --profile in mozrunner just blows away addon sources:
    16     https://bugzilla.mozilla.org/show_bug.cgi?id=758250
    17     """
    19     def setUp(self):
    20         self.tmpdir = tempfile.mkdtemp()
    21         self.addon = os.path.join(here, 'addons', 'empty')
    23     def tearDown(self):
    24         # remove vestiges
    25         shutil.rmtree(self.tmpdir)
    27     def test_profile_addon_cleanup(self):
    29         # sanity check: the empty addon should be here
    30         self.assertTrue(os.path.exists(self.addon))
    31         self.assertTrue(os.path.isdir(self.addon))
    32         self.assertTrue(os.path.exists(os.path.join(self.addon, 'install.rdf')))
    34         # because we are testing data loss, let's make sure we make a copy
    35         shutil.rmtree(self.tmpdir)
    36         shutil.copytree(self.addon, self.tmpdir)
    37         self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'install.rdf')))
    39         # make a starter profile
    40         profile = mozprofile.FirefoxProfile()
    41         path = profile.profile
    43         # make a new profile based on the old
    44         newprofile = mozprofile.FirefoxProfile(profile=path, addons=[self.tmpdir])
    45         newprofile.cleanup()
    47         # the source addon *should* still exist
    48         self.assertTrue(os.path.exists(self.tmpdir))
    49         self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'install.rdf')))
    52 if __name__ == '__main__':
    53     unittest.main()

mercurial