@@ -35,8 +35,8 @@ test_that("qualified names returned when ns given", {
3535 bars <- xml_children(xml_children(x ))
3636 attr <- xml_attrs(bars , ns )
3737
38- expect_equal(names( attr [[1 ]]) , " f:id" )
39- expect_equal(names( attr [[2 ]]) , " g:id" )
38+ expect_named( attr [[1 ]], " f:id" )
39+ expect_named( attr [[2 ]], " g:id" )
4040})
4141
4242
@@ -150,21 +150,21 @@ test_that("xml_attr<- removes namespaces if desired", {
150150 x <- read_xml(" <a xmlns = 'tag:foo'><b/></a>" )
151151
152152 # cannot find //b with a default namespace
153- expect_equal(length( xml_find_all(x , " //b" ) ), 0 )
153+ expect_length( xml_find_all(x , " //b" ), 0 )
154154
155155 # unless we specify it explicitly
156- expect_equal(length( xml_find_all(x , " //b" ) ), 0 )
157- expect_equal(length( xml_find_all(x , " //d1:b" , xml_ns(x ) )), 1 )
156+ expect_length( xml_find_all(x , " //b" ), 0 )
157+ expect_length( xml_find_all(x , " //d1:b" , xml_ns(x )), 1 )
158158
159159 # but can find it once we remove the namespace
160160 xml_attr(x , " xmlns" ) <- NULL
161- expect_equal(length( xml_find_all(x , " //b" ) ), 1 )
161+ expect_length( xml_find_all(x , " //b" ), 1 )
162162
163163 # and add the old namespace back
164164 xml_attr(x , " xmlns" ) <- " tag:foo"
165165 expect_equal(xml_attr(x , " xmlns" ), " tag:foo" )
166- expect_equal(length( xml_find_all(x , " //b" ) ), 0 )
167- expect_equal(length( xml_find_all(x , " //d1:b" , xml_ns(x ) )), 1 )
166+ expect_length( xml_find_all(x , " //b" ), 0 )
167+ expect_length( xml_find_all(x , " //d1:b" , xml_ns(x )), 1 )
168168
169169 expect_equal(xml_attr(x , " xmlns" ), " tag:foo" )
170170})
@@ -173,22 +173,22 @@ test_that("xml_attr<- removes prefixed namespaces if desired", {
173173 x <- read_xml(" <a xmlns:pre = 'tag:foo'><pre:b/></a>" )
174174
175175 # cannot find //b with a prefixed namespace
176- expect_equal(length( xml_find_all(x , " //b" ) ), 0 )
176+ expect_length( xml_find_all(x , " //b" ), 0 )
177177
178178 # unless we specify it explicitly
179- expect_equal(length( xml_find_all(x , " //b" ) ), 0 )
180- expect_equal(length( xml_find_all(x , " //pre:b" , xml_ns(x ) )), 1 )
179+ expect_length( xml_find_all(x , " //b" ), 0 )
180+ expect_length( xml_find_all(x , " //pre:b" , xml_ns(x )), 1 )
181181
182182 # but can find it once we remove the namespace
183183 xml_attr(x , " xmlns:pre" ) <- NULL
184- expect_equal(length( xml_find_all(x , " //b" ) ), 1 )
184+ expect_length( xml_find_all(x , " //b" ), 1 )
185185
186186 # and add the old namespace back
187187 xml_attr(x , " xmlns:pre" ) <- " tag:foo"
188188 xml_set_namespace(xml_children(x )[[1 ]], " pre" )
189189 expect_equal(xml_attr(x , " xmlns:pre" ), " tag:foo" )
190- expect_equal(length( xml_find_all(x , " //b" ) ), 0 )
191- expect_equal(length( xml_find_all(x , " //pre:b" , xml_ns(x ) )), 1 )
190+ expect_length( xml_find_all(x , " //b" ), 0 )
191+ expect_length( xml_find_all(x , " //pre:b" , xml_ns(x )), 1 )
192192
193193 expect_equal(xml_attr(x , " xmlns:pre" ), " tag:foo" )
194194})
@@ -213,8 +213,8 @@ test_that("xml_set_attr works identically to xml_attr<-", {
213213
214214 # No errors for xml_missing
215215 mss <- xml_find_first(bx , " ./c" )
216- expect_error (xml_attr(mss [[2 ]], " b" ) <- " blah" , NA )
217- expect_error (xml_set_attr(mss [[2 ]], " b" , " blah" ), NA )
216+ expect_no_error (xml_attr(mss [[2 ]], " b" ) <- " blah" )
217+ expect_no_error (xml_set_attr(mss [[2 ]], " b" , " blah" ))
218218})
219219
220220test_that(" xml_set_attrs works identically to xml_attrs<-" , {
@@ -237,8 +237,8 @@ test_that("xml_set_attrs works identically to xml_attrs<-", {
237237
238238 # No errors for xml_missing
239239 mss <- xml_find_first(bx , " ./c" )
240- expect_error (xml_attrs(mss [[2 ]]) <- c(" b" = " blah" ), NA )
241- expect_error (xml_set_attrs(mss [[2 ]], c(" b" = " blah" )), NA )
240+ expect_no_error (xml_attrs(mss [[2 ]]) <- c(" b" = " blah" ))
241+ expect_no_error (xml_set_attrs(mss [[2 ]], c(" b" = " blah" )))
242242})
243243
244244test_that(" xml_set_attr can set the same namespace multiple times" , {
0 commit comments