[test] Use our BaseTestCase in unittest_rtags.py
We need it DeprecatedInstanceWithoutModule for assertWarns method. Use this
instead of unittest2 directly with a try/except block to get rid of flake8
error about import not being one top of file.
--- a/cubicweb/test/unittest_rtags.py Mon Jan 30 10:22:23 2017 +0100
+++ b/cubicweb/test/unittest_rtags.py Mon Jan 30 11:23:13 2017 +0100
@@ -16,17 +16,11 @@
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-import sys
-if sys.version_info[:2] < (3, 2):
- # assertWarns appears in 3.2
- import unittest2 as unittest
-else:
- import unittest
-
+from cubicweb.devtools.testlib import BaseTestCase
from cubicweb.rtags import RelationTags, RelationTagsSet, RelationTagsDict
-class RelationTagsTC(unittest.TestCase):
+class RelationTagsTC(BaseTestCase):
def setUp(self):
self.rtags = RelationTags(__module__=__name__)
@@ -66,7 +60,7 @@
'hidden')
-class RelationTagsSetTC(unittest.TestCase):
+class RelationTagsSetTC(BaseTestCase):
def setUp(self):
self.rtags = RelationTagsSet(__module__=__name__)
@@ -99,7 +93,7 @@
set())
-class RelationTagsDictTC(unittest.TestCase):
+class RelationTagsDictTC(BaseTestCase):
def setUp(self):
self.rtags = RelationTagsDict(__module__=__name__)
@@ -143,7 +137,7 @@
{'key0': 'val00', 'key4': 'val4'})
-class DeprecatedInstanceWithoutModule(unittest.TestCase):
+class DeprecatedInstanceWithoutModule(BaseTestCase):
def test_deprecated_instance_without_module(self):
class SubRelationTags(RelationTags):
@@ -156,4 +150,5 @@
if __name__ == '__main__':
+ import unittest
unittest.main()