Lines Matching refs:self
25 def test_createFromLine(self): argument
27 self.assertTrue(p.is_comment())
28 self.assertEqual("", p.name)
29 self.assertEqual("", p.value)
30 self.assertFalse(p.is_optional())
31 self.assertEqual("# this is comment", str(p))
35 self.assertFalse(p.is_comment())
36 self.assertEqual("a", p.name)
37 self.assertEqual("b", p.value)
38 self.assertFalse(p.is_optional())
39 self.assertEqual("a=b", str(p))
43 self.assertFalse(p.is_comment())
44 self.assertEqual("a", p.name)
45 self.assertEqual("b", p.value)
46 self.assertTrue(p.is_optional())
47 self.assertEqual("a?=b", str(p))
49 def test_makeAsComment(self): argument
52 self.assertFalse(p.is_comment())
55 self.assertTrue(p.is_comment())
56 self.assertTrue("# a comment\n#a=b", str(p))
59 def setUp(self): argument
68 self.patcher = patch("post_process_props.open", mock_open(read_data=content))
69 self.mock_open = self.patcher.start()
70 self.props = PropList("file")
72 def tearDown(self): argument
73 self.patcher.stop()
74 self.props = None
76 def test_readFromFile(self): argument
77 self.assertEqual(4, len(self.props.get_all_props()))
84 for i,p in enumerate(self.props.get_all_props()):
85 self.assertEqual(expected[i][0], p.name)
86 self.assertEqual(expected[i][1], p.value)
87 self.assertEqual(expected[i][2], p.is_optional())
88 self.assertFalse(p.is_comment())
90 self.assertEqual(set(["foo", "bar", "qux"]), self.props.get_all_names())
92 self.assertEqual("true", self.props.get_value("foo"))
93 self.assertEqual("false", self.props.get_value("bar"))
94 self.assertEqual("1", self.props.get_value("qux"))
97 self.assertEqual(2, len(self.props.get_props("foo")))
99 def test_putNewProp(self): argument
100 self.props.put("new", "30")
102 self.assertEqual(5, len(self.props.get_all_props()))
103 last_prop = self.props.get_all_props()[-1]
104 self.assertEqual("new", last_prop.name)
105 self.assertEqual("30", last_prop.value)
106 self.assertFalse(last_prop.is_optional())
108 def test_putExistingNonOptionalProp(self): argument
109 self.props.put("foo", "NewValue")
111 self.assertEqual(4, len(self.props.get_all_props()))
112 foo_prop = self.props.get_props("foo")[0]
113 self.assertEqual("foo", foo_prop.name)
114 self.assertEqual("NewValue", foo_prop.value)
115 self.assertFalse(foo_prop.is_optional())
116 self.assertEqual("# Value overridden by post_process_props.py. " +
119 def test_putExistingOptionalProp(self): argument
120 self.props.put("qux", "2")
122 self.assertEqual(5, len(self.props.get_all_props()))
123 last_prop = self.props.get_all_props()[-1]
124 self.assertEqual("qux", last_prop.name)
125 self.assertEqual("2", last_prop.value)
126 self.assertFalse(last_prop.is_optional())
127 self.assertEqual("# Auto-added by post_process_props.py\nqux=2",
130 def test_deleteNonOptionalProp(self): argument
131 props_to_delete = self.props.get_props("foo")[0]
134 self.assertEqual(3, len(self.props.get_all_props()))
135 self.assertEqual("# Removed by post_process_props.py because testing\n" +
138 def test_deleteOptionalProp(self): argument
139 props_to_delete = self.props.get_props("qux")[0]
142 self.assertEqual(3, len(self.props.get_all_props()))
143 self.assertEqual("# Removed by post_process_props.py because testing\n" +
146 def test_overridingNonOptional(self): argument
147 props_to_be_overridden = self.props.get_props("foo")[1]
148 self.assertTrue("true", props_to_be_overridden.value)
150 self.assertTrue(override_optional_props(self.props))
153 self.assertEqual(3, len(self.props.get_all_props()))
155 self.assertEqual(1, len(self.props.get_props("foo")))
156 self.assertEqual("true", self.props.get_props("foo")[0].value)
158 self.assertEqual("# Removed by post_process_props.py because " +
162 def test_overridingOptional(self): argument
176 self.assertEqual("2", props_to_be_overridden.value)
178 self.assertTrue(override_optional_props(props))
180 self.assertEqual(1, len(props.get_props("qux")))
181 self.assertEqual("1", props.get_props("qux")[0].value)
183 self.assertFalse(props.get_props("qux")[0].is_optional())
185 self.assertEqual("# Removed by post_process_props.py because " +
189 def test_overridingDuplicated(self): argument
205 self.assertFalse(override_optional_props(props))
207 self.assertEqual("error: found duplicate sysprop assignments:\n" +
210 def test_overridingDuplicatedWithSameValue(self): argument
228 self.assertTrue(override_optional_props(props))
231 self.assertEqual("# Removed by post_process_props.py because " +
235 def test_allowDuplicates(self): argument
252 self.assertTrue(override_optional_props(props, allow_dup=True))