testing/mozbase/mozprofile/tests/bug758250.py

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:3a7015578ace
1 #!/usr/bin/env python
2
3 import mozprofile
4 import os
5 import shutil
6 import tempfile
7 import unittest
8
9
10 here = os.path.dirname(os.path.abspath(__file__))
11
12
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 """
18
19 def setUp(self):
20 self.tmpdir = tempfile.mkdtemp()
21 self.addon = os.path.join(here, 'addons', 'empty')
22
23 def tearDown(self):
24 # remove vestiges
25 shutil.rmtree(self.tmpdir)
26
27 def test_profile_addon_cleanup(self):
28
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')))
33
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')))
38
39 # make a starter profile
40 profile = mozprofile.FirefoxProfile()
41 path = profile.profile
42
43 # make a new profile based on the old
44 newprofile = mozprofile.FirefoxProfile(profile=path, addons=[self.tmpdir])
45 newprofile.cleanup()
46
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')))
50
51
52 if __name__ == '__main__':
53 unittest.main()

mercurial