|
7 | 7 | import operator |
8 | 8 | from typing import NamedTuple |
9 | 9 | from typing import Any |
| 10 | +import warnings |
10 | 11 |
|
| 12 | +import httpx |
11 | 13 | import pytest |
12 | 14 | from rdflib import BNode, Graph, Literal, URIRef, XSD |
13 | 15 | from rdflib.compare import isomorphic |
| 16 | +from sparqlx import SPARQLWrapper |
| 17 | +from sparqlx.utils.operation_parameters import ( |
| 18 | + rdf_response_format_map, |
| 19 | + sparql_result_response_format_map, |
| 20 | +) |
14 | 21 |
|
15 | 22 | from conftest import FusekiEndpoints, RDFLibGraphEndpoints |
16 | 23 | from data.queries import ( |
|
22 | 29 | select_query_types, |
23 | 30 | select_query_xy_values, |
24 | 31 | ) |
25 | | -import httpx |
26 | | -from sparqlx import SPARQLWrapper |
27 | | -from sparqlx.utils.operation_parameters import ( |
28 | | - rdf_response_format_map, |
29 | | - sparql_result_response_format_map, |
30 | | -) |
31 | 32 | from utils import acall |
32 | 33 |
|
33 | 34 |
|
@@ -309,12 +310,23 @@ async def test_sparqlwrapper_streaming(query_method, query, triplestore): |
309 | 310 | ], |
310 | 311 | ) |
311 | 312 | def test_sparqlwrapper_queries(query_method, query, triplestore): |
| 313 | + """Compare the results of SPARQLWrapper.queries and manually running SPARQLWrapper.aquery. |
| 314 | +
|
| 315 | + The test also checks that no client manager warnings are emitted |
| 316 | + from SPARQLWrapper.queries. This is achieved by locally setting |
| 317 | + the warnings filter to raise an error for all warnings; |
| 318 | + i.e. if no warning is emitted, the test passes because no exceptions |
| 319 | + are raised from any warning. |
| 320 | + """ |
| 321 | + |
312 | 322 | endpoint = triplestore.sparql_endpoint |
313 | 323 | sparqlwrapper = SPARQLWrapper(sparql_endpoint=endpoint, query_method=query_method) |
314 | 324 |
|
315 | 325 | queries: list[str] = [query for _ in range(5)] |
316 | 326 |
|
317 | | - results_queries = sparqlwrapper.queries(*queries) |
| 327 | + with warnings.catch_warnings(): |
| 328 | + warnings.simplefilter("error") |
| 329 | + results_queries = sparqlwrapper.queries(*queries) |
318 | 330 |
|
319 | 331 | async def _runner(): |
320 | 332 | async with asyncio.TaskGroup() as tg: |
|
0 commit comments