@@ -34,7 +34,7 @@ def test_binding_replace():
34
34
g .bind ("foaf" , FOAF1 )
35
35
g .bind ("foaf2" , FOAF2 )
36
36
assert len (list (g .namespaces ())) == 2
37
- assert list (g .namespaces ()) == [(' foaf' , foaf1_uri ), ("foaf2" , foaf2_uri )]
37
+ assert list (g .namespaces ()) == [(" foaf" , foaf1_uri ), ("foaf2" , foaf2_uri )]
38
38
39
39
# Now you want to "upgrade" to FOAF2=>foaf and try the obvious:
40
40
g .bind ("foaf" , FOAF2 )
@@ -61,7 +61,7 @@ def test_binding_replace():
61
61
62
62
assert list (g .namespaces ()) == [
63
63
("foaf" , foaf2_uri ), # Should be present but has been removed.
64
- (' oldfoaf' , foaf1_uri ),
64
+ (" oldfoaf" , foaf1_uri ),
65
65
]
66
66
67
67
# 2. Changing the prefix of an existing namespace=>prefix binding:
@@ -72,7 +72,7 @@ def test_binding_replace():
72
72
73
73
# Which, as things stand, results in:
74
74
75
- assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (' foaf1' , foaf1_uri )]
75
+ assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (" foaf1" , foaf1_uri )]
76
76
77
77
# In which the attempted change from `oldfoaf` to (the already
78
78
# bound-to-a different-namespace `foaf`) was intercepted and
@@ -82,13 +82,13 @@ def test_binding_replace():
82
82
g .bind ("oldfoaf" , FOAF1 , replace = True )
83
83
84
84
# The bindings are again as desired
85
- assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (' oldfoaf' , foaf1_uri )]
85
+ assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (" oldfoaf" , foaf1_uri )]
86
86
87
87
# Next time through, set override to False
88
88
g .bind ("foaf" , FOAF1 , override = False )
89
89
90
90
# And the bindings will remain as desired
91
- assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (' oldfoaf' , foaf1_uri )]
91
+ assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (" oldfoaf" , foaf1_uri )]
92
92
93
93
# 3. Parsing data with prefix=>namespace bindings
94
94
# Let's see the situation regarding namespace bindings
@@ -108,7 +108,7 @@ def test_binding_replace():
108
108
# non-clashing prefix of `foaf1` is rebound to FOAF1 in
109
109
# place of the existing `oldfoaf` prefix
110
110
111
- assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (' foaf1' , foaf1_uri )]
111
+ assert list (g .namespaces ()) == [("foaf" , foaf2_uri ), (" foaf1" , foaf1_uri )]
112
112
113
113
# Yes, namespace bindings in parsed data replace existing
114
114
# bindings (i.e. `oldfoaf` was replaced by `foaf1`), just
@@ -128,7 +128,7 @@ def test_binding_replace():
128
128
# by the `foaf2=>FOAF2` binding specified in the N3 source
129
129
130
130
assert list (g .namespaces ()) == [
131
- (' foaf1' , foaf1_uri ),
131
+ (" foaf1" , foaf1_uri ),
132
132
("foaf2" , foaf2_uri ),
133
133
]
134
134
@@ -146,7 +146,7 @@ def test_binding_replace():
146
146
# used
147
147
148
148
assert list (g .namespaces ()) == [
149
- (' foaf1' , foaf1_uri ),
149
+ (" foaf1" , foaf1_uri ),
150
150
("foaf2" , foaf2_uri ),
151
151
]
152
152
@@ -161,7 +161,7 @@ def test_binding_replace():
161
161
162
162
assert list (g .namespaces ()) == [
163
163
("foaf2" , foaf2_uri ),
164
- (' foaf' , foaf1_uri ),
164
+ (" foaf" , foaf1_uri ),
165
165
]
166
166
167
167
# Prefixes are bound to namespaces which in turn have a URIRef
@@ -191,11 +191,11 @@ def test_prefix_alias_disallowed():
191
191
192
192
g = Graph (bind_namespaces = "none" )
193
193
g .bind ("owl" , OWL )
194
- assert (' owl' , URIRef (' http://www.w3.org/2002/07/owl#' )) in list (g .namespaces ())
194
+ assert (" owl" , URIRef (" http://www.w3.org/2002/07/owl#" )) in list (g .namespaces ())
195
195
196
196
g .bind ("wol" , OWL , override = False )
197
- assert (' owl' , URIRef (' http://www.w3.org/2002/07/owl#' )) in list (g .namespaces ())
198
- assert (' wol' , URIRef (' http://www.w3.org/2002/07/owl#' )) not in list (g .namespaces ())
197
+ assert (" owl" , URIRef (" http://www.w3.org/2002/07/owl#" )) in list (g .namespaces ())
198
+ assert (" wol" , URIRef (" http://www.w3.org/2002/07/owl#" )) not in list (g .namespaces ())
199
199
200
200
201
201
def test_rebind_prefix_succeeds ():
@@ -204,11 +204,11 @@ def test_rebind_prefix_succeeds():
204
204
205
205
g = Graph (bind_namespaces = "none" )
206
206
g .bind ("owl" , OWL )
207
- assert (' owl' , URIRef (' http://www.w3.org/2002/07/owl#' )) in list (g .namespaces ())
207
+ assert (" owl" , URIRef (" http://www.w3.org/2002/07/owl#" )) in list (g .namespaces ())
208
208
209
209
g .bind ("wol" , OWL )
210
- assert (' wol' , URIRef (' http://www.w3.org/2002/07/owl#' )) in list (g .namespaces ())
211
- assert (' owl' , URIRef (' http://www.w3.org/2002/07/owl#' )) not in list (g .namespaces ())
210
+ assert (" wol" , URIRef (" http://www.w3.org/2002/07/owl#" )) in list (g .namespaces ())
211
+ assert (" owl" , URIRef (" http://www.w3.org/2002/07/owl#" )) not in list (g .namespaces ())
212
212
213
213
214
214
def test_parse_rebinds_prefix ():
@@ -223,14 +223,14 @@ def test_parse_rebinds_prefix():
223
223
224
224
# Use full set of namespace bindings, including foaf
225
225
g = Graph (bind_namespaces = "none" )
226
- g .bind (' foaf' , FOAF1 )
227
- assert (' foaf' , foaf1_uri ) in list (g .namespaces ())
226
+ g .bind (" foaf" , FOAF1 )
227
+ assert (" foaf" , foaf1_uri ) in list (g .namespaces ())
228
228
229
229
g .parse (data = data , format = "n3" )
230
230
231
231
# foaf no longer in set of namespace bindings
232
- assert (' foaf' , foaf1_uri ) not in list (g .namespaces ())
233
- assert (' friend-of-a-friend' , foaf1_uri ) in list (g .namespaces ())
232
+ assert (" foaf" , foaf1_uri ) not in list (g .namespaces ())
233
+ assert (" friend-of-a-friend" , foaf1_uri ) in list (g .namespaces ())
234
234
235
235
236
236
@pytest .mark .xfail (
@@ -254,7 +254,7 @@ def test_automatic_handling_of_unknown_predicates():
254
254
255
255
g = Graph (bind_namespaces = "none" )
256
256
257
- g .add ((tarek , URIRef (' http://xmlns.com/foaf/0.1/name' ), Literal ("Tarek" )))
257
+ g .add ((tarek , URIRef (" http://xmlns.com/foaf/0.1/name" ), Literal ("Tarek" )))
258
258
259
259
assert len (list (g .namespaces ())) > 0
260
260
@@ -263,7 +263,7 @@ def test_automatic_handling_of_unknown_predicates_only_effected_after_serializat
263
263
264
264
g = Graph (bind_namespaces = "none" )
265
265
266
- g .add ((tarek , URIRef (' http://xmlns.com/foaf/0.1/name' ), Literal ("Tarek" )))
266
+ g .add ((tarek , URIRef (" http://xmlns.com/foaf/0.1/name" ), Literal ("Tarek" )))
267
267
268
268
assert "@prefix ns1: <http://xmlns.com/foaf/0.1/> ." in g .serialize (format = "n3" )
269
269
@@ -282,27 +282,27 @@ def test_multigraph_bindings():
282
282
283
283
g1 = Graph (store , identifier = context1 , bind_namespaces = "none" )
284
284
285
- g1 .bind (' foaf' , FOAF1 )
286
- assert list (g1 .namespaces ()) == [(' foaf' , foaf1_uri )]
287
- assert list (store .namespaces ()) == [(' foaf' , foaf1_uri )]
285
+ g1 .bind (" foaf" , FOAF1 )
286
+ assert list (g1 .namespaces ()) == [(" foaf" , foaf1_uri )]
287
+ assert list (store .namespaces ()) == [(" foaf" , foaf1_uri )]
288
288
289
289
g1 .add ((tarek , FOAF1 .name , Literal ("tarek" )))
290
290
291
- assert list (store .namespaces ()) == [(' foaf' , foaf1_uri )]
291
+ assert list (store .namespaces ()) == [(" foaf" , foaf1_uri )]
292
292
293
293
g2 = Graph (store , identifier = context2 , bind_namespaces = "none" )
294
294
g2 .parse (data = data , format = "n3" )
295
295
296
296
# The parser-caused rebind is in the underlying store and all objects
297
297
# that use the store see the changed binding:
298
- assert list (store .namespaces ()) == [(' friend-of-a-friend' , foaf1_uri )]
299
- assert list (g1 .namespaces ()) == [(' friend-of-a-friend' , foaf1_uri )]
298
+ assert list (store .namespaces ()) == [(" friend-of-a-friend" , foaf1_uri )]
299
+ assert list (g1 .namespaces ()) == [(" friend-of-a-friend" , foaf1_uri )]
300
300
301
301
# Including newly-created objects that use the store
302
302
cg = ConjunctiveGraph (store = store )
303
303
304
- assert (' foaf' , foaf1_uri ) not in list (cg .namespaces ())
305
- assert (' friend-of-a-friend' , foaf1_uri ) in list (cg .namespaces ())
304
+ assert (" foaf" , foaf1_uri ) not in list (cg .namespaces ())
305
+ assert (" friend-of-a-friend" , foaf1_uri ) in list (cg .namespaces ())
306
306
307
307
assert len (list (g1 .namespaces ())) == 6
308
308
assert len (list (g2 .namespaces ())) == 6
@@ -324,24 +324,24 @@ def test_multigraph_bindings():
324
324
325
325
# Add foaf2 binding if not already bound
326
326
cg .bind ("foaf2" , FOAF2 , override = False )
327
- assert (' foaf2' , foaf2_uri ) in list (cg .namespaces ())
327
+ assert (" foaf2" , foaf2_uri ) in list (cg .namespaces ())
328
328
329
329
# Impose foaf binding ... if not already bound
330
330
cg .bind ("foaf" , FOAF1 , override = False )
331
- assert (' foaf' , foaf1_uri ) not in list (cg .namespaces ())
331
+ assert (" foaf" , foaf1_uri ) not in list (cg .namespaces ())
332
332
333
333
334
334
def test_new_namespace_new_prefix ():
335
335
g = Graph (bind_namespaces = "none" )
336
336
g .bind ("foaf" , FOAF1 )
337
- assert list (g .namespaces ()) == [(' foaf' , foaf1_uri )]
337
+ assert list (g .namespaces ()) == [(" foaf" , foaf1_uri )]
338
338
339
339
340
340
def test_change_prefix_override_true ():
341
341
g = Graph (bind_namespaces = "none" )
342
342
343
343
g .bind ("foaf" , FOAF1 )
344
- assert list (g .namespaces ()) == [(' foaf' , foaf1_uri )]
344
+ assert list (g .namespaces ()) == [(" foaf" , foaf1_uri )]
345
345
346
346
g .bind ("oldfoaf" , FOAF1 )
347
347
# Changed
@@ -352,7 +352,7 @@ def test_change_prefix_override_false():
352
352
g = Graph (bind_namespaces = "none" )
353
353
354
354
g .bind ("foaf" , FOAF1 )
355
- assert list (g .namespaces ()) == [(' foaf' , foaf1_uri )]
355
+ assert list (g .namespaces ()) == [(" foaf" , foaf1_uri )]
356
356
357
357
g .bind ("oldfoaf" , FOAF1 , override = False )
358
358
# No change
@@ -363,7 +363,7 @@ def test_change_namespace_override_true():
363
363
g = Graph (bind_namespaces = "none" )
364
364
365
365
g .bind ("foaf" , FOAF1 )
366
- assert list (g .namespaces ()) == [(' foaf' , foaf1_uri )]
366
+ assert list (g .namespaces ()) == [(" foaf" , foaf1_uri )]
367
367
368
368
g .bind ("foaf" , FOAF2 )
369
369
# Different prefix used
@@ -374,7 +374,7 @@ def test_change_namespace_override_false():
374
374
g = Graph (bind_namespaces = "none" )
375
375
376
376
g .bind ("foaf" , FOAF1 )
377
- assert list (g .namespaces ()) == [(' foaf' , foaf1_uri )]
377
+ assert list (g .namespaces ()) == [(" foaf" , foaf1_uri )]
378
378
379
379
# Different namespace so override is irrelevant in this case
380
380
g .bind ("foaf" , FOAF2 , override = False )
@@ -386,14 +386,14 @@ def test_new_namespace_override_false():
386
386
g = Graph (bind_namespaces = "none" )
387
387
388
388
g .bind ("foaf" , FOAF2 )
389
- assert list (g .namespaces ()) == [(' foaf' , foaf2_uri )]
389
+ assert list (g .namespaces ()) == [(" foaf" , foaf2_uri )]
390
390
391
391
# Namespace not already bound so override is irrelevant in this case
392
392
g .bind ("owl" , OWL , override = False )
393
393
# Given prefix used
394
394
assert list (g .namespaces ()) == [
395
395
("foaf" , foaf2_uri ),
396
- (' owl' , URIRef (' http://www.w3.org/2002/07/owl#' )),
396
+ (" owl" , URIRef (" http://www.w3.org/2002/07/owl#" )),
397
397
]
398
398
399
399
@@ -406,7 +406,7 @@ def test_change_namespace_and_prefix():
406
406
g = Graph (bind_namespaces = "none" )
407
407
408
408
g .bind ("foaf" , FOAF1 )
409
- assert list (g .namespaces ()) == [(' foaf' , foaf1_uri )]
409
+ assert list (g .namespaces ()) == [(" foaf" , foaf1_uri )]
410
410
411
411
g .bind ("foaf" , FOAF2 , replace = True )
412
412
assert list (g .namespaces ()) == [("foaf" , foaf2_uri )]
0 commit comments