Skip to content

Commit ffeec85

Browse files
committed
Switching to pytest
- nose no longer works on Python 3.10 and the maintainer cannot be bothered to learn how nose2 wants to work
1 parent c3253ae commit ffeec85

File tree

6 files changed

+25
-28
lines changed

6 files changed

+25
-28
lines changed

test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
flake8
22
mock==3.0.5 ; python_version=="2.7"
3-
nose2[coverage_plugin]
43
tox

test/test_sqlalchemy_mysql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import unittest
44

5-
from nose import SkipTest
5+
import pytest
66
from rdflib import Literal
77
from rdflib.graph import ConjunctiveGraph as Graph
88
from six import PY3
@@ -19,18 +19,21 @@
1919
assert mysql
2020
dialect = "mysqlconnector"
2121
except ImportError:
22-
raise SkipTest("MySQL-connector not found, skipping MySQL tests")
22+
pytest.skip("MySQL-connector not found, skipping MySQL tests",
23+
allow_module_level=True)
2324
else:
2425
try:
2526
import MySQLdb
2627
assert MySQLdb
2728
dialect = "mysqldb"
2829
except ImportError:
29-
raise SkipTest("MySQLdb not found, skipping MySQL tests")
30+
pytest.skip("MySQLdb not found, skipping MySQL tests",
31+
allow_module_level=True)
3032

3133

3234
if os.environ.get("DB") != "mysql":
33-
raise SkipTest("MySQL not under test")
35+
pytest.skip("MySQL not under test",
36+
allow_module_level=True)
3437

3538
_logger = logging.getLogger(__name__)
3639

@@ -67,7 +70,7 @@ def tearDown(self):
6770
super(SQLAMySQLContextTestCase, self).tearDown(uri=self.uri)
6871

6972
def testLenInMultipleContexts(self):
70-
raise SkipTest("Known issue.")
73+
pytest.skip("Known issue.")
7174

7275

7376
class SQLAMySQLIssueTestCase(unittest.TestCase):

test/test_sqlalchemy_postgresql.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
import os
33
import unittest
44

5-
from nose import SkipTest
5+
import pytest
66
try:
77
import psycopg2 # noqa
8+
assert psycopg2 # quiets unused import warning
89
except ImportError:
9-
raise SkipTest("psycopg2 not installed, skipping PgSQL tests")
10+
pytest.skip("psycopg2 not installed, skipping PgSQL tests",
11+
allow_module_level=True)
1012

1113
from . import context_case
1214
from . import graph_case
1315

1416

1517
if os.environ.get("DB") != "pgsql":
16-
raise SkipTest("PgSQL not under test")
18+
pytest.skip("PgSQL not under test", allow_module_level=True)
1719

1820
sqlalchemy_url = os.environ.get(
1921
"DBURI",
@@ -54,7 +56,7 @@ def tearDown(self):
5456
super(SQLAPgSQLContextTestCase, self).tearDown(uri=self.uri)
5557

5658
def testLenInMultipleContexts(self):
57-
raise SkipTest("Known issue.")
59+
pytest.skip("Known issue.")
5860

5961

6062
SQLAPgSQLGraphTestCase.storetest = True

test/test_sqlalchemy_postgresql_pg8000.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
import os
44
import unittest
55

6-
from nose import SkipTest
6+
import pytest
77
try:
88
import pg8000
99
assert pg8000 is not None
1010
except ImportError:
11-
raise SkipTest("pg8000 not installed, skipping PgSQL tests")
11+
pytest.skip("pg8000 not installed, skipping PgSQL tests",
12+
allow_module_level=True)
1213

1314
from . import context_case
1415
from . import graph_case
1516

1617

1718
if os.environ.get("DB") != "pgsql":
18-
raise SkipTest("PgSQL not under test")
19+
pytest.skip("PgSQL not under test", allow_module_level=True)
1920

2021
_logger = logging.getLogger(__name__)
2122

@@ -61,7 +62,7 @@ def tearDown(self):
6162

6263
def testLenInMultipleContexts(self):
6364
"""Test lin in multiple contexts, known issue."""
64-
raise SkipTest("Known issue.")
65+
pytest.skip("Known issue.")
6566

6667
# SQLAPgSQLGraphTestCase.storetest = True
6768
# SQLAPgSQLContextTestCase.storetest = True

test/test_sqlalchemy_sqlite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import os
33
import unittest
44

5-
from nose import SkipTest
5+
import pytest
66
from rdflib import Literal
77

88
from . import context_case
99
from . import graph_case
1010

1111

1212
if os.environ.get("DB") != "sqlite":
13-
raise SkipTest("SQLite not under test")
13+
pytest.skip("SQLite not under test", allow_module_level=True)
1414

1515
_logger = logging.getLogger(__name__)
1616

@@ -43,7 +43,7 @@ def tearDown(self):
4343
super(SQLASQLiteContextTestCase, self).tearDown(uri=self.uri)
4444

4545
def testLenInMultipleContexts(self):
46-
raise SkipTest("Known issue.")
46+
pytest.skip("Known issue.")
4747

4848

4949
SQLASQLiteGraphTestCase.storetest = True

tox.ini

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ envlist =
66
passenv = DB DBURI
77
commands =
88
{envpython} setup.py clean --all
9-
nosetests --with-coverage --cover-package=rdflib_sqlalchemy \
10-
--cover-inclusive --cover-branches
9+
pytest --cov=rdflib_sqlalchemy
1110

1211
deps =
12+
pytest>=3.4.0
13+
pytest-cov>=2.5.1
1314
psycopg2
1415
mysqlclient
1516
py{37,38,39,310}: mysql-connector
@@ -19,15 +20,6 @@ commands = flake8 rdflib_sqlalchemy test
1920
deps =
2021
flake8
2122

22-
[testenv:cover]
23-
basepython = python3.7
24-
commands =
25-
nosetests --with-coverage --cover-html --cover-html-dir=./coverage \
26-
--cover-package=rdflib_sqlalchemy --cover-inclusive
27-
deps =
28-
psycopg2
29-
mysqlclient
30-
3123
[travis]
3224
python =
3325
2.7: py27, lint

0 commit comments

Comments
 (0)