Skip to content

Commit

Permalink
feat: Use conftest.py for global fixture definitions
Browse files Browse the repository at this point in the history
Importing fixtures is a pytest antipattern and causes Ruff to flag F811.
See astral-sh/ruff#4046.
Defining fixtures globally in conftest.py is the idiomatic way to
remedy the problem.
  • Loading branch information
lu-pl committed Jul 26, 2024
1 parent f4c0448 commit d6c439d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Conftest.py for RDFProxy."""

import pytest

from SPARQLWrapper import JSON, SPARQLWrapper


def _sparql_wrapper_fixture_factory(endpoint: str, return_format=JSON):
"""Return a SPARQLWrapper fixture with the endpoint and return format_set."""

@pytest.fixture
def sparql_wrapper():
sparql = SPARQLWrapper(endpoint)
sparql.setReturnFormat(return_format)
return sparql

return sparql_wrapper


wikidata_wrapper = _sparql_wrapper_fixture_factory(
"https://query.wikidata.org/bigdata/namespace/wdq/sparql"
)

0 comments on commit d6c439d

Please sign in to comment.