diff --git a/test/graph_case.py b/test/graph_case.py index ab45a2a..141c8c0 100644 --- a/test/graph_case.py +++ b/test/graph_case.py @@ -10,6 +10,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") @@ -22,13 +26,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): diff --git a/test/test_sqlalchemy_mysql.py b/test/test_sqlalchemy_mysql.py index 6cb6fa0..2212fef 100644 --- a/test/test_sqlalchemy_mysql.py +++ b/test/test_sqlalchemy_mysql.py @@ -39,12 +39,6 @@ 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 @@ -52,13 +46,6 @@ class SQLAMySQLContextTestCase(context_case.ContextTestCase): 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.") diff --git a/test/test_sqlalchemy_postgresql.py b/test/test_sqlalchemy_postgresql.py index a2ec044..4c83022 100644 --- a/test/test_sqlalchemy_postgresql.py +++ b/test/test_sqlalchemy_postgresql.py @@ -30,15 +30,6 @@ 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 @@ -46,15 +37,6 @@ class SQLAPgSQLContextTestCase(context_case.ContextTestCase): 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.") diff --git a/test/test_sqlalchemy_postgresql_pg8000.py b/test/test_sqlalchemy_postgresql_pg8000.py index 407791e..8da93fa 100644 --- a/test/test_sqlalchemy_postgresql_pg8000.py +++ b/test/test_sqlalchemy_postgresql_pg8000.py @@ -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", @@ -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.""" @@ -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.") diff --git a/test/test_sqlalchemy_sqlite.py b/test/test_sqlalchemy_sqlite.py index e7ad1fe..dc9876b 100644 --- a/test/test_sqlalchemy_sqlite.py +++ b/test/test_sqlalchemy_sqlite.py @@ -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.")