Skip to content

Commit 6a82d8a

Browse files
committed
make sure that the tests are actually executed in tox with Python 2.7
1 parent a7752c1 commit 6a82d8a

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,9 @@ def use_educated_guess(self):
836836
},
837837
)
838838

839+
if sys.version_info <= (2, 7):
840+
options["requires"] = options.pop("install_requires")
841+
839842
if sys.version_info > (3, 0):
840843
options["use_2to3"] = True
841844

src/_igraph/attributes.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ int igraphmodule_i_attribute_struct_index_vertex_names(
8787
PyErr_Format(
8888
PyExc_RuntimeError,
8989
"error while indexing vertex names; did you accidentally try to "
90-
"use a non-hashable object as a vertex name earlier? "
91-
"Check the name of vertex %R (%R)", value, key
90+
"use a non-hashable object as a vertex name earlier?"
91+
#ifdef IGRAPH_PYTHON3
92+
/* %R is not supported in Python 2.x */
93+
" Check the name of vertex %R (%R)", value, key
94+
#endif
9295
);
9396
}
9497

tests/test_attributes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# vim:ts=4 sw=4 sts=4:
2+
import sys
23
import unittest
34
from igraph import *
45

@@ -102,7 +103,8 @@ def testUnhashableVertexNames(self):
102103

103104
# Check the exception
104105
self.assertTrue(isinstance(err, RuntimeError))
105-
self.assertTrue(repr(value) in str(err))
106+
if sys.version_info >= (3, 4):
107+
self.assertTrue(repr(value) in str(err))
106108

107109
def testVertexNameIndexingBug196(self):
108110
g = Graph()

tests/test_foreign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def testPickle(self):
226226
pickle = bytes(pickle)
227227
else:
228228
pickle = "".join(map(chr, pickle))
229-
with temporary_file(pickle, "wb") as tmpfname:
229+
with temporary_file(pickle, "wb", binary=True) as tmpfname:
230230
g = Graph.Read_Pickle(pickle)
231231
self.assertTrue(isinstance(g, Graph))
232232
self.assertTrue(g.vcount() == 3 and g.ecount() == 1 and

tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def skipIf(condition, reason):
4747

4848

4949
@contextmanager
50-
def temporary_file(content=None, mode=None):
50+
def temporary_file(content=None, mode=None, binary=False):
5151
tmpf, tmpfname = tempfile.mkstemp()
5252
os.close(tmpf)
5353

@@ -59,7 +59,7 @@ def temporary_file(content=None, mode=None):
5959

6060
tmpf = open(tmpfname, mode)
6161
if content is not None:
62-
if hasattr(content, "encode"):
62+
if hasattr(content, "encode") and not binary:
6363
tmpf.write(dedent(content).encode("utf8"))
6464
else:
6565
tmpf.write(content)

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ deps =
1414
setenv =
1515
TESTING_IN_TOX=1
1616

17+
[testenv:py27]
18+
commands = python -m unittest discover
19+
1720
[flake8]
1821
max-line-length = 80
1922
select = C,E,F,W,B,B950

0 commit comments

Comments
 (0)