diff --git a/.gitignore b/.gitignore index fd20fdd..cd61e2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ - +#ignore local enviroment +/env *.pyc diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..cdc30ca --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "tests/main.py", + "console": "integratedTerminal", + "justMyCode": true + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..38d90d5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "python.testing.unittestArgs": [ + "-v", + "-s", + "./tests", + "-p", + "**.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true, + "files.exclude": { + "**/.git": true, + "**/__pycache__": true, + "**/utils":true + } +} \ No newline at end of file diff --git a/VERSION b/VERSION index d6a1063..0457540 100644 --- a/VERSION +++ b/VERSION @@ -1,13 +1,13 @@ -PureMVC Standard Framework for Python (Ported) +PureMVC Standard Framework for Python (Ported) -------------------------------------------------------------------------- Release Date: 03/16/09 - Platform: Python 2.5 + Platform: Python 3.11 Version: 1 - Revision: 2 + Revision: 4 Minor: 0 Author: Toby de Havilland -------------------------------------------------------------------------- - +1.4 - * Fixed iteraion in dict and Tests to be identified by vscode 1.3 - * Fixed name clashes with built-in types * Refactored unit test primer to auto-load unit tests * Fixed bug in MacroCommand.execute() where the list of commands was diff --git a/src/puremvc/core.py b/src/puremvc/core.py index 16eb138..35a492f 100644 --- a/src/puremvc/core.py +++ b/src/puremvc/core.py @@ -369,6 +369,9 @@ def removeMediator(self, mediatorName): @param mediatorName: name of the C{IMediator} instance to be removed. @return: the C{IMediator} that was removed from the C{View} """ + + deleteList=[]#list to collect all items needed to be delete + for notificationName in self.observerMap.keys(): observers = self.observerMap[notificationName] for i in range(len(observers)-1, -1, -1): @@ -376,7 +379,12 @@ def removeMediator(self, mediatorName): observers.pop(i) if len(observers) == 0: - del self.observerMap[notificationName] + deleteList.append(notificationName)#instead of delete put on a list + #del self.observerMap[notificationName] + + #delete all in once to avoid error of collection change + for item in deleteList: + del self.observerMap[item] mediator = self.mediatorMap.get(mediatorName) diff --git a/tests/core/controller.py b/tests/core/controller.py index 5e198a8..d66473f 100644 --- a/tests/core/controller.py +++ b/tests/core/controller.py @@ -1,4 +1,8 @@ import unittest +import sys + +sys.path.insert(1, "src") + import puremvc.interfaces import puremvc.patterns.observer import puremvc.core diff --git a/tests/core/model.py b/tests/core/model.py index 445fdee..3750526 100644 --- a/tests/core/model.py +++ b/tests/core/model.py @@ -1,4 +1,7 @@ import unittest +import sys + +sys.path.insert(1, "src") import puremvc.interfaces import puremvc.patterns.proxy diff --git a/tests/core/view.py b/tests/core/view.py index 6f418dc..f929964 100644 --- a/tests/core/view.py +++ b/tests/core/view.py @@ -1,4 +1,7 @@ import unittest +import sys + +sys.path.insert(1, "src") import puremvc.interfaces import puremvc.patterns.observer diff --git a/tests/patterns/command.py b/tests/patterns/command.py index 53a06e5..b3487aa 100644 --- a/tests/patterns/command.py +++ b/tests/patterns/command.py @@ -1,5 +1,7 @@ import unittest +import sys +sys.path.insert(1, "src") import puremvc.patterns.observer import utils.command @@ -12,7 +14,7 @@ def testMacroCommandExecute(self): vo = utils.command.MacroCommandTestVO(5) note = puremvc.patterns.observer.Notification('MacroCommandTest', vo) command = utils.command.MacroCommandTestCommand() - command.execute(note); + command.execute(note) self.assertEqual(True, vo.result1 == 10) self.assertEqual(True, vo.result2 == 25) @@ -23,6 +25,6 @@ def testSimpleCommandExecute(self): vo = utils.command.SimpleCommandTestVO(5) note = puremvc.patterns.observer.Notification('SimpleCommandTestNote', vo) command = utils.command.SimpleCommandTestCommand() - command.execute(note); + command.execute(note) self.assertEqual(True, vo.result == 10) diff --git a/tests/patterns/facade.py b/tests/patterns/facade.py index 27a8e69..c967651 100644 --- a/tests/patterns/facade.py +++ b/tests/patterns/facade.py @@ -1,5 +1,7 @@ import unittest +import sys +sys.path.insert(1, "src") import puremvc.interfaces import puremvc.patterns.proxy import puremvc.patterns.mediator diff --git a/tests/patterns/mediator.py b/tests/patterns/mediator.py index c448355..592fcdf 100644 --- a/tests/patterns/mediator.py +++ b/tests/patterns/mediator.py @@ -1,5 +1,7 @@ import unittest +import sys +sys.path.insert(1, "src") import puremvc.patterns.mediator as mediator class MediatorTest(unittest.TestCase): diff --git a/tests/patterns/observer.py b/tests/patterns/observer.py index 2088797..b425a95 100644 --- a/tests/patterns/observer.py +++ b/tests/patterns/observer.py @@ -1,5 +1,7 @@ import unittest +import sys +sys.path.insert(1, "src") import puremvc.patterns.observer class ObserverTest(unittest.TestCase): diff --git a/tests/patterns/proxy.py b/tests/patterns/proxy.py index 2dd5924..dcc0fe3 100644 --- a/tests/patterns/proxy.py +++ b/tests/patterns/proxy.py @@ -1,5 +1,7 @@ import unittest +import sys +sys.path.insert(1, "src") import puremvc.patterns.proxy class ProxyTest(unittest.TestCase):