Skip to content

Commit 5ffc72a

Browse files
committed
Adding a dependency on "mock" for Python 2
1 parent 23db75d commit 5ffc72a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
2+
import sys
3+
24
from setuptools import setup
35

6+
PY2 = sys.version_info.major == 2
47

58
project = "rdflib-sqlalchemy"
69
version = "0.3.8"
@@ -53,7 +56,9 @@
5356
setup_requires=[
5457
"nose>=1.3.6",
5558
],
56-
tests_require="coveralls",
59+
tests_require=[
60+
"coveralls"
61+
] + (['mock'] if PY2 else []),
5762
test_suite="nose.collector",
5863
entry_points={
5964
'rdf.plugins.store': [

test/test_sqlalchemy.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import unittest
2-
from unittest.mock import patch
2+
3+
try:
4+
from unittest.mock import patch
5+
except ImportError:
6+
from mock import patch
37

48
from rdflib import (
59
ConjunctiveGraph,
@@ -40,7 +44,7 @@ def test_success(self):
4044
p.create_engine.assert_called_with('sqlite://', random_key='something')
4145

4246
def test_no_url(self):
43-
with patch('rdflib_sqlalchemy.store.sqlalchemy') as p:
47+
with patch('rdflib_sqlalchemy.store.sqlalchemy'):
4448
with self.assertRaisesRegex(Exception, '.*url.*'):
4549
self.graph.open({'random_key': 'something'}, create=True)
4650

0 commit comments

Comments
 (0)