Mercurial > hg > configuration
annotate tests/unit.py @ 103:982a775bf3d2
call the proper method
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 01 May 2012 10:46:26 -0700 |
parents | c530f6265deb |
children | a2184db43fe2 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 unit tests | |
5 """ | |
6 | |
30
b27a7cb2dd5b
stub test for configuration providers
Jeff Hammel <jhammel@mozilla.com>
parents:
28
diff
changeset
|
7 import configuration |
0 | 8 import os |
9 import sys | |
32
da4d5c5831c6
serialization testing stubbing
Jeff Hammel <jhammel@mozilla.com>
parents:
30
diff
changeset
|
10 import tempfile |
0 | 11 import unittest |
12 | |
32
da4d5c5831c6
serialization testing stubbing
Jeff Hammel <jhammel@mozilla.com>
parents:
30
diff
changeset
|
13 try: |
da4d5c5831c6
serialization testing stubbing
Jeff Hammel <jhammel@mozilla.com>
parents:
30
diff
changeset
|
14 import json |
da4d5c5831c6
serialization testing stubbing
Jeff Hammel <jhammel@mozilla.com>
parents:
30
diff
changeset
|
15 except ImportError: |
da4d5c5831c6
serialization testing stubbing
Jeff Hammel <jhammel@mozilla.com>
parents:
30
diff
changeset
|
16 import simplejson as json |
da4d5c5831c6
serialization testing stubbing
Jeff Hammel <jhammel@mozilla.com>
parents:
30
diff
changeset
|
17 |
19
cadc9514f60a
we have a legitimately failing test!
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
18 from example import ExampleConfiguration # example configuration to test |
11
e00afe2c83bf
stubbing configuration parser
Jeff Hammel <jhammel@mozilla.com>
parents:
0
diff
changeset
|
19 |
0 | 20 # globals |
21 here = os.path.dirname(os.path.abspath(__file__)) | |
22 | |
24
39f2611db9be
rename a bunch of things and begin to work on the sanity of validation
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
23 class ConfigurationUnitTest(unittest.TestCase): |
0 | 24 |
24
39f2611db9be
rename a bunch of things and begin to work on the sanity of validation
Jeff Hammel <jhammel@mozilla.com>
parents:
19
diff
changeset
|
25 def test_cli(self): |
28
c516ab813079
begin stubbing serialization/deserialization
Jeff Hammel <jhammel@mozilla.com>
parents:
25
diff
changeset
|
26 """test command line interface""" |
c516ab813079
begin stubbing serialization/deserialization
Jeff Hammel <jhammel@mozilla.com>
parents:
25
diff
changeset
|
27 |
19
cadc9514f60a
we have a legitimately failing test!
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
28 example = ExampleConfiguration() |
cadc9514f60a
we have a legitimately failing test!
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
29 |
cadc9514f60a
we have a legitimately failing test!
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
30 # parse command line arguments |
65
2a2e9aee5bc6
refactor completed and tests pass again
Jeff Hammel <jhammel@mozilla.com>
parents:
58
diff
changeset
|
31 options, args = example.parse_args(['-a', 'ts', '--develop', '-e', '/home/jhammel/bin/firefox']) |
25
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
32 |
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
33 # ensure that the options appropriately get set |
19
cadc9514f60a
we have a legitimately failing test!
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
34 self.assertEqual(bool(args), False) # no arguments |
cadc9514f60a
we have a legitimately failing test!
Jeff Hammel <jhammel@mozilla.com>
parents:
11
diff
changeset
|
35 self.assertEqual(options.develop, True) |
25
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
36 self.assertEqual(options.activeTests, ['ts']) |
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
37 self.assertEqual(options.browser_path, '/home/jhammel/bin/firefox') |
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
38 |
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
39 # ensure that the configuration appropriately gets updated |
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
40 self.assertEqual(example.config['develop'], True) |
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
41 self.assertEqual(example.config['activeTests'], ['ts']) |
b39e550402ea
we now update configuration correctly
Jeff Hammel <jhammel@mozilla.com>
parents:
24
diff
changeset
|
42 self.assertEqual(example.config['browser_path'], '/home/jhammel/bin/firefox') |
0 | 43 |
28
c516ab813079
begin stubbing serialization/deserialization
Jeff Hammel <jhammel@mozilla.com>
parents:
25
diff
changeset
|
44 def test_configuration_providers(self): |
c516ab813079
begin stubbing serialization/deserialization
Jeff Hammel <jhammel@mozilla.com>
parents:
25
diff
changeset
|
45 """test file-based configuration providers""" |
39
3c91bf85adb5
actually test serialization
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
46 # requires json/simplejson to be installed |
30
b27a7cb2dd5b
stub test for configuration providers
Jeff Hammel <jhammel@mozilla.com>
parents:
28
diff
changeset
|
47 |
b27a7cb2dd5b
stub test for configuration providers
Jeff Hammel <jhammel@mozilla.com>
parents:
28
diff
changeset
|
48 example = ExampleConfiguration() |
b27a7cb2dd5b
stub test for configuration providers
Jeff Hammel <jhammel@mozilla.com>
parents:
28
diff
changeset
|
49 |
b27a7cb2dd5b
stub test for configuration providers
Jeff Hammel <jhammel@mozilla.com>
parents:
28
diff
changeset
|
50 # see what providers you got |
b27a7cb2dd5b
stub test for configuration providers
Jeff Hammel <jhammel@mozilla.com>
parents:
28
diff
changeset
|
51 json_provider = example.configuration_provider('json') |
b27a7cb2dd5b
stub test for configuration providers
Jeff Hammel <jhammel@mozilla.com>
parents:
28
diff
changeset
|
52 self.assertTrue(isinstance(json_provider, configuration.JSON)) |
28
c516ab813079
begin stubbing serialization/deserialization
Jeff Hammel <jhammel@mozilla.com>
parents:
25
diff
changeset
|
53 |
33
b7d6a90b0bb5
setup for serialization testing
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
54 # serialize to a temporary file |
37
a1f8dec4d4f9
we has another broken test
Jeff Hammel <jhammel@mozilla.com>
parents:
36
diff
changeset
|
55 filename = tempfile.mktemp(suffix='.json') |
38
8909ae1cc4ea
fix serialization (stub) tests
Jeff Hammel <jhammel@mozilla.com>
parents:
37
diff
changeset
|
56 self.assertEqual(example.filename2format(filename), 'json') |
37
a1f8dec4d4f9
we has another broken test
Jeff Hammel <jhammel@mozilla.com>
parents:
36
diff
changeset
|
57 self.assertFalse(os.path.exists(filename)) |
34
79aca36abd9a
fill in defaults if not present
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
58 config = {'browser_path': '/home/jhammel/bin/firefox', |
79aca36abd9a
fill in defaults if not present
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
59 'activeTests': ['ts']} |
79aca36abd9a
fill in defaults if not present
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
60 example(config) |
79aca36abd9a
fill in defaults if not present
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
61 config['test_timeout'] = 1200 # default |
102
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
62 config['preferences'] = {"browser.bookmarks.max_backups": 0, |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
63 "browser.cache.disk.smart_size.enabled": False} |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
64 |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
65 # ensure they are equal |
34
79aca36abd9a
fill in defaults if not present
Jeff Hammel <jhammel@mozilla.com>
parents:
33
diff
changeset
|
66 self.assertEqual(config, example.config) |
37
a1f8dec4d4f9
we has another broken test
Jeff Hammel <jhammel@mozilla.com>
parents:
36
diff
changeset
|
67 example.serialize(filename) |
a1f8dec4d4f9
we has another broken test
Jeff Hammel <jhammel@mozilla.com>
parents:
36
diff
changeset
|
68 self.assertTrue(os.path.exists(filename)) |
39
3c91bf85adb5
actually test serialization
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
69 serialized = json.loads(file(filename).read()) |
3c91bf85adb5
actually test serialization
Jeff Hammel <jhammel@mozilla.com>
parents:
38
diff
changeset
|
70 self.assertEqual(serialized, config) |
42 | 71 |
72 # deserialize | |
73 deserialized = example.deserialize(filename) | |
74 self.assertEqual(deserialized, config) | |
75 | |
76 # cleanup | |
33
b7d6a90b0bb5
setup for serialization testing
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
77 if os.path.exists(filename): |
b7d6a90b0bb5
setup for serialization testing
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
78 os.remove(filename) |
b7d6a90b0bb5
setup for serialization testing
Jeff Hammel <jhammel@mozilla.com>
parents:
32
diff
changeset
|
79 |
48
84fb8ad5ba81
ensure that missing values raise the correct exception
Jeff Hammel <jhammel@mozilla.com>
parents:
43
diff
changeset
|
80 def test_missing_values(self): |
84fb8ad5ba81
ensure that missing values raise the correct exception
Jeff Hammel <jhammel@mozilla.com>
parents:
43
diff
changeset
|
81 """ensure that Configuration raises a missing value exception""" |
84fb8ad5ba81
ensure that missing values raise the correct exception
Jeff Hammel <jhammel@mozilla.com>
parents:
43
diff
changeset
|
82 |
84fb8ad5ba81
ensure that missing values raise the correct exception
Jeff Hammel <jhammel@mozilla.com>
parents:
43
diff
changeset
|
83 example = ExampleConfiguration() |
84fb8ad5ba81
ensure that missing values raise the correct exception
Jeff Hammel <jhammel@mozilla.com>
parents:
43
diff
changeset
|
84 |
89
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
85 # monkey-patch the error method from optparse.OptionParser |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
86 error_msg = [] |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
87 def error(msg): |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
88 error_msg.append(msg) |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
89 example.error = error |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
90 |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
91 # trigger it |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
92 example.parse_args(args=[]) |
0804a706d6bf
handle CLI errors with optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
65
diff
changeset
|
93 self.assertEqual(error_msg, ['Parameter browser_path is required but not present']) |
48
84fb8ad5ba81
ensure that missing values raise the correct exception
Jeff Hammel <jhammel@mozilla.com>
parents:
43
diff
changeset
|
94 |
36
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
95 def test_required(self): |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
96 """ensure you have to have required values""" |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
97 |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
98 example = ExampleConfiguration() |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
99 |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
100 # ensure you get an exception |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
101 missingvalueexception = None |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
102 try: |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
103 example() |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
104 except configuration.MissingValueException, e: |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
105 missingvalueexception = e |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
106 self.assertTrue(isinstance(e, configuration.MissingValueException)) |
d218df4d0b4c
add test for missing values
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
107 |
102
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
108 |
40
056280e7a6ea
stub munging configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
109 def test_multiple_configurations(self): |
056280e7a6ea
stub munging configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
110 """test having multiple configurations""" |
056280e7a6ea
stub munging configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
111 |
056280e7a6ea
stub munging configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
112 # simple override |
056280e7a6ea
stub munging configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
113 args1 = ['-e', '/opt/bin/firefox'] |
056280e7a6ea
stub munging configuration
Jeff Hammel <jhammel@mozilla.com>
parents:
39
diff
changeset
|
114 |
55 | 115 # simple serialized file |
116 json_file = os.path.join(here, 'base.json') | |
117 assert os.path.exists(json_file) | |
118 json_config = json.loads(file(json_file).read()) | |
119 | |
120 # parse the json file | |
121 example = ExampleConfiguration() | |
65
2a2e9aee5bc6
refactor completed and tests pass again
Jeff Hammel <jhammel@mozilla.com>
parents:
58
diff
changeset
|
122 example.parse_args([json_file]) |
55 | 123 self.assertEqual(example.config, json_config) |
124 | |
125 # parse the json file with overrides | |
126 example = ExampleConfiguration() | |
65
2a2e9aee5bc6
refactor completed and tests pass again
Jeff Hammel <jhammel@mozilla.com>
parents:
58
diff
changeset
|
127 example.parse_args([json_file] + args1) |
55 | 128 config = json_config.copy() |
129 config['browser_path'] = '/opt/bin/firefox' | |
130 self.assertEqual(example.config, config) | |
43 | 131 |
56
7f8e9c5d1606
introduce a somewhat redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
55
diff
changeset
|
132 # it shouldn't matter in which order the arguments are |
7f8e9c5d1606
introduce a somewhat redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
55
diff
changeset
|
133 example = ExampleConfiguration() |
65
2a2e9aee5bc6
refactor completed and tests pass again
Jeff Hammel <jhammel@mozilla.com>
parents:
58
diff
changeset
|
134 example.parse_args(args1 + [json_file]) |
56
7f8e9c5d1606
introduce a somewhat redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
55
diff
changeset
|
135 self.assertEqual(example.config, config) |
7f8e9c5d1606
introduce a somewhat redundant test
Jeff Hammel <jhammel@mozilla.com>
parents:
55
diff
changeset
|
136 |
58
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
137 # Now a tricky case: |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
138 # the default value for test_timeout is 1200: |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
139 example = ExampleConfiguration() |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
140 self.assertEqual(example.options['test_timeout']['default'], 1200) |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
141 # The value from base.json is 60: |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
142 self.assertEqual(json_config['test_timeout'], 60) |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
143 self.assertEqual(config['test_timeout'], 60) |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
144 # but we can override it back from the "command line" |
65
2a2e9aee5bc6
refactor completed and tests pass again
Jeff Hammel <jhammel@mozilla.com>
parents:
58
diff
changeset
|
145 example.parse_args(args1 + [json_file, '--test_timeout', '1200']) |
58
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
146 config['test_timeout'] = 1200 |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
147 self.assertEqual(example.config, config) |
f7dc5cf2540c
add complex test, now we can refactor
Jeff Hammel <jhammel@mozilla.com>
parents:
56
diff
changeset
|
148 |
102
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
149 def test_extend(self): |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
150 |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
151 # default preferences |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
152 example = ExampleConfiguration() |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
153 default_prefs = {"browser.bookmarks.max_backups": 0, |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
154 "browser.cache.disk.smart_size.enabled": False} |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
155 example.parse_args(['-a', 'ts', '-e', '/opt/bin/firefox']) |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
156 self.assertEqual(example.config['preferences'], default_prefs) |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
157 |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
158 # now extend them |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
159 example = ExampleConfiguration() |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
160 default_prefs['network.dns.ipv4OnlyDomains'] = 'localhost' |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
161 tf = tempfile.mktemp() |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
162 f = file(tf, 'w') |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
163 f.write(json.dumps({'preferences': {'network.dns.ipv4OnlyDomains': 'localhost'}})) |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
164 f.close() |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
165 example.parse_args(['-a', 'ts', '-e', '/opt/bin/firefox', tf]) |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
166 self.assertEqual(example.config['preferences'], default_prefs) |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
167 os.remove(tf) |
c530f6265deb
allow extensible configuration; also start using deepcopy heavily since otherwise you have artefacts
Jeff Hammel <jhammel@mozilla.com>
parents:
89
diff
changeset
|
168 |
0 | 169 if __name__ == '__main__': |
170 unittest.main() |