[gedit-plugins/sessionsaver] standard behavior for new



commit d3d76c615a60937df21b9b0ad3af8e21e5670239
Author: Jordi Mas <jmas softcatala org>
Date:   Tue Jul 2 23:39:33 2019 +0200

    standard behavior for new

 plugins/sessionsaver/sessionsaver/store/sessionstore.py |  6 ------
 plugins/sessionsaver/tests/testsessionstore.py          | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/plugins/sessionsaver/sessionsaver/store/sessionstore.py 
b/plugins/sessionsaver/sessionsaver/store/sessionstore.py
index f1a44e0..dd80a9a 100644
--- a/plugins/sessionsaver/sessionsaver/store/sessionstore.py
+++ b/plugins/sessionsaver/sessionsaver/store/sessionstore.py
@@ -34,12 +34,6 @@ class SessionStore(GObject.Object):
                             (GObject.TYPE_PYOBJECT,))
     }
 
-    _instance = None
-    def __new__(cls):
-        if cls._instance is None:
-            cls._instance = GObject.Object.__new__(cls)
-        return cls._instance
-
     def __init__(self):
         super(SessionStore, self).__init__()
         self._sessions = []
diff --git a/plugins/sessionsaver/tests/testsessionstore.py b/plugins/sessionsaver/tests/testsessionstore.py
index 270f9d6..7e50cb7 100644
--- a/plugins/sessionsaver/tests/testsessionstore.py
+++ b/plugins/sessionsaver/tests/testsessionstore.py
@@ -24,6 +24,20 @@ from store.sessionstore import SessionStore
 
 class TestSessionStore(unittest.TestCase):
 
+    def test_new_two_objects(self):
+        session_a = Session("session_A")
+        store_a = SessionStore()
+        store_a.add(session_a)
+
+        session_b = Session("session_B")
+        session_c = Session("session_C")
+        store_b = SessionStore()
+        store_b.add(session_b)
+        store_b.add(session_c)
+
+        self.assertEqual(1, len(store_a))
+        self.assertEqual(2, len(store_b))
+
     def test_add(self):
         session = Session("session_A")
         store = SessionStore()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]