# HG changeset patch # User Denis Laxalde # Date 1477463674 -7200 # Node ID b57b76091481410976db6e27f8cdebcf52922c3f # Parent 18e7b9829471362561119698823bb500d9174eaf [devtools] Make dependency on backports.tempfile (Python2) optional The package may not be available in all systems (e.g. no Debian package exist at the moment), and we should not crash with ImportError when importing testlib from client code. Follow up on a6dc650bc230 where the dependency was introduced. diff -r 18e7b9829471 -r b57b76091481 cubicweb/devtools/testlib.py --- a/cubicweb/devtools/testlib.py Wed Sep 28 22:17:36 2016 +0200 +++ b/cubicweb/devtools/testlib.py Wed Oct 26 08:34:34 2016 +0200 @@ -57,7 +57,11 @@ from unittest2 import TestCase if not hasattr(TestCase, 'subTest'): raise ImportError('no subTest support in available unittest2') - from backports.tempfile import TemporaryDirectory # noqa + try: + from backports.tempfile import TemporaryDirectory # noqa + except ImportError: + # backports.tempfile not available + TemporaryDirectory = None else: from unittest import TestCase from tempfile import TemporaryDirectory # noqa