浏览代码

Add test for stop error when not in stoppable state

Mike Naberezny 11 年之前
父节点
当前提交
f2866e3ae5
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      supervisor/tests/test_process.py

+ 16 - 0
supervisor/tests/test_process.py

@@ -661,6 +661,22 @@ class SubprocessTests(unittest.TestCase):
         self.assertEqual(instance.killing, 1)
         self.assertEqual(options.kills[11], signal.SIGTERM)
 
+    def test_stop_not_in_stoppable_state_error(self):
+        options = DummyOptions()
+        config = DummyPConfig(options, 'test', '/test')
+        instance = self._makeOne(config)
+        instance.pid = 11
+        dispatcher = DummyDispatcher(writable=True)
+        instance.dispatchers = {'foo':dispatcher}
+        from supervisor.states import ProcessStates
+        instance.state = ProcessStates.STOPPED
+        try:
+            instance.stop()
+            fail('nothing raised')
+        except AssertionError, exc:
+            self.assertEqual(exc.args[0], 'Assertion failed for test: '
+                'STOPPED not in RUNNING STARTING STOPPING')
+
     def test_give_up(self):
         options = DummyOptions()
         config = DummyPConfig(options, 'test', '/test')