cubicweb/test/unittest_rtags.py
changeset 11932 7b2247098f58
parent 11888 0849a5eb57b8
child 11935 963b71128396
--- a/cubicweb/test/unittest_rtags.py	Fri Jan 27 17:42:16 2017 +0100
+++ b/cubicweb/test/unittest_rtags.py	Fri Jan 20 16:39:44 2017 +0100
@@ -16,7 +16,12 @@
 # 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 unittest
+import sys
+if sys.version_info[:2] < (3, 2):
+    # assertWarns appears in 3.2
+    import unittest2 as unittest
+else:
+    import unittest
 
 from cubicweb.rtags import RelationTags, RelationTagsSet, RelationTagsDict
 
@@ -24,7 +29,7 @@
 class RelationTagsTC(unittest.TestCase):
 
     def setUp(self):
-        self.rtags = RelationTags()
+        self.rtags = RelationTags(__module__=__name__)
         self.rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary')
         self.rtags.tag_subject_of(('*', 'evaluee', '*'), 'secondary')
         self.rtags.tag_object_of(('*', 'tags', '*'), 'generated')
@@ -64,7 +69,7 @@
 class RelationTagsSetTC(unittest.TestCase):
 
     def setUp(self):
-        self.rtags = RelationTagsSet()
+        self.rtags = RelationTagsSet(__module__=__name__)
         self.rtags.tag_subject_of(('Societe', 'travaille', '*'), 'primary')
         self.rtags.tag_subject_of(('*', 'travaille', '*'), 'secondary')
 
@@ -97,7 +102,7 @@
 class RelationTagsDictTC(unittest.TestCase):
 
     def setUp(self):
-        self.rtags = RelationTagsDict()
+        self.rtags = RelationTagsDict(__module__=__name__)
         self.rtags.tag_subject_of(('Societe', 'travaille', '*'),
                                   {'key1': 'val1', 'key2': 'val1'})
         self.rtags.tag_subject_of(('*', 'travaille', '*'),
@@ -138,5 +143,17 @@
                          {'key0': 'val00', 'key4': 'val4'})
 
 
+class DeprecatedInstanceWithoutModule(unittest.TestCase):
+
+    def test_deprecated_instance_without_module(self):
+        class SubRelationTags(RelationTags):
+            pass
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            'instantiate SubRelationTags with __module__=__name__',
+        ):
+            SubRelationTags()
+
+
 if __name__ == '__main__':
     unittest.main()