Skip to content

Align setUp and tearDown type signatures with unittest and rdflib.plugin #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions test/graph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class GraphTestCase(unittest.TestCase):
storetest = True
identifier = URIRef("rdflib_test")

# storename is expected to be assigned in subclasses.
storename: str
uri: str = "sqlite://"

michel = URIRef(u"michel")
tarek = URIRef(u"tarek")
bob = URIRef(u"bob")
Expand All @@ -23,13 +27,13 @@ class GraphTestCase(unittest.TestCase):
namespace_dct = "http://purl.org/dc/terms/"
namespace_saws = "http://purl.org/saws/ontology#"

def setUp(self, uri="sqlite://", storename=None):
store = plugin.get(storename, Store)(identifier=self.identifier)
def setUp(self) -> None:
store = plugin.get(self.storename, Store)(identifier=self.identifier)
self.graph = Graph(store, identifier=self.identifier)
self.graph.open(uri, create=True)
self.graph.open(self.uri, create=True)

def tearDown(self, uri="sqlite://"):
self.graph.destroy(uri)
def tearDown(self) -> None:
self.graph.destroy(self.uri)
self.graph.close()

def addStuff(self):
Expand Down
13 changes: 0 additions & 13 deletions test/test_sqlalchemy_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,13 @@ class SQLAMySQLGraphTestCase(graph_case.GraphTestCase):
uri = sqlalchemy_url
create = True

def setUp(self):
super(SQLAMySQLGraphTestCase, self).setUp(uri=self.uri, storename=self.storename)

def tearDown(self):
super(SQLAMySQLGraphTestCase, self).tearDown(uri=self.uri)


class SQLAMySQLContextTestCase(context_case.ContextTestCase):
storetest = True
storename = "SQLAlchemy"
uri = sqlalchemy_url
create = True

def setUp(self):
super(SQLAMySQLContextTestCase, self).setUp(
uri=self.uri, storename=self.storename)

def tearDown(self):
super(SQLAMySQLContextTestCase, self).tearDown(uri=self.uri)

def testLenInMultipleContexts(self):
pytest.skip("Known issue.")

Expand Down
18 changes: 0 additions & 18 deletions test/test_sqlalchemy_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,13 @@ class SQLAPgSQLGraphTestCase(graph_case.GraphTestCase):
uri = sqlalchemy_url
create = True

def setUp(self):
super(SQLAPgSQLGraphTestCase, self).setUp(
uri=self.uri,
storename=self.storename,
)

def tearDown(self):
super(SQLAPgSQLGraphTestCase, self).tearDown(uri=self.uri)


class SQLAPgSQLContextTestCase(context_case.ContextTestCase):
storetest = True
storename = "SQLAlchemy"
uri = sqlalchemy_url
create = True

def setUp(self):
super(SQLAPgSQLContextTestCase, self).setUp(
uri=self.uri,
storename=self.storename,
)

def tearDown(self):
super(SQLAPgSQLContextTestCase, self).tearDown(uri=self.uri)

def testLenInMultipleContexts(self):
pytest.skip("Known issue.")

Expand Down
20 changes: 1 addition & 19 deletions test/test_sqlalchemy_postgresql_pg8000.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
try:
import pg8000
import pg8000 # type: ignore
assert pg8000 is not None
except ImportError:
pytest.skip("pg8000 not installed, skipping PgSQL tests",
Expand Down Expand Up @@ -33,15 +33,6 @@ class SQLAPgSQLGraphTestCase(graph_case.GraphTestCase):
uri = sqlalchemy_url
create = True

def setUp(self):
"""Setup."""
super(SQLAPgSQLGraphTestCase, self).setUp(
uri=self.uri, storename=self.storename)

def tearDown(self):
"""Teardown."""
super(SQLAPgSQLGraphTestCase, self).tearDown(uri=self.uri)


class SQLAPgSQLContextTestCase(context_case.ContextTestCase):
"""Context test case."""
Expand All @@ -51,15 +42,6 @@ class SQLAPgSQLContextTestCase(context_case.ContextTestCase):
uri = sqlalchemy_url
create = True

def setUp(self):
"""Setup."""
super(SQLAPgSQLContextTestCase, self).setUp(
uri=self.uri, storename=self.storename)

def tearDown(self):
"""Teardown."""
super(SQLAPgSQLContextTestCase, self).tearDown(uri=self.uri)

def testLenInMultipleContexts(self):
"""Test lin in multiple contexts, known issue."""
pytest.skip("Known issue.")
Expand Down
14 changes: 0 additions & 14 deletions test/test_sqlalchemy_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,12 @@ class SQLASQLiteGraphTestCase(graph_case.GraphTestCase):
storename = "SQLAlchemy"
uri = sqlalchemy_url

def setUp(self):
super(SQLASQLiteGraphTestCase, self).setUp(
uri=self.uri, storename=self.storename)

def tearDown(self):
super(SQLASQLiteGraphTestCase, self).tearDown(uri=self.uri)


class SQLASQLiteContextTestCase(context_case.ContextTestCase):
storetest = True
storename = "SQLAlchemy"
uri = sqlalchemy_url

def setUp(self):
super(SQLASQLiteContextTestCase, self).setUp(
uri=self.uri, storename=self.storename)

def tearDown(self):
super(SQLASQLiteContextTestCase, self).tearDown(uri=self.uri)

def testLenInMultipleContexts(self):
pytest.skip("Known issue.")

Expand Down