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.

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

mercurial