[PATCH 07 of 10 logilab-database] [test] Force module reload in test_only_one_lazy_module_initialization

Denis Laxalde denis.laxalde at logilab.fr
Mon Jun 4 12:00:22 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1528102910 -7200
#      Mon Jun 04 11:01:50 2018 +0200
# Node ID 49f291df9e68cce2ebff9c30b95e8f2d41420c59
# Parent  a53d453a0b82866e7ce95d87fa2a819ec5862353
# Available At https://hg.logilab.org/review/logilab/database
#              hg pull https://hg.logilab.org/review/logilab/database -r 49f291df9e68
# EXP-Topic py3
[test] Force module reload in test_only_one_lazy_module_initialization

Otherwise, when all tests are run together the module might already have
been loaded by another test, which makes the assertion break.

diff --git a/test/unittest_sqlite.py b/test/unittest_sqlite.py
--- a/test/unittest_sqlite.py
+++ b/test/unittest_sqlite.py
@@ -20,6 +20,7 @@ import sqlite3
 from datetime import datetime
 
 from dateutil.tz import tzutc
+from six.moves import reload_module
 
 from logilab.common.testlib import MockConnection
 
@@ -44,6 +45,7 @@ class SQLiteHelperTC(unittest.TestCase):
 class SQLiteAdapterTC(unittest.TestCase):
 
     def test_only_one_lazy_module_initialization(self):
+        reload_module(lgdbsqlite)
         self.assertFalse(lgdbsqlite._Sqlite3Adapter._module_is_initialized)
         adapter = lgdbsqlite._Sqlite3Adapter(sqlite3)
         self.assertTrue(adapter._module_is_initialized)


More information about the cubicweb-devel mailing list