Debian Codegraph @

testing/mozbase/mozprofile/tests/test_bug758250.py

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