示例#1
0
 def test_remove_EACCES(self, unlink):
     exc = OSError()
     exc.errno = errno.EACCES
     unlink.side_effect = exc
     p = PIDFile("/var/pid")
     p.remove()
     unlink.assert_called_with(p.path)
示例#2
0
 def test_remove_EACCES(self, unlink):
     exc = OSError()
     exc.errno = errno.EACCES
     unlink.side_effect = exc
     p = PIDFile('/var/pid')
     p.remove()
     unlink.assert_called_with(p.path)
示例#3
0
 def test_remove_ENOENT(self, unlink):
     exc = OSError()
     exc.errno = errno.ENOENT
     unlink.side_effect = exc
     p = PIDFile("/var/pid")
     p.remove()
     unlink.assert_called_with(p.path)
 def test_remove_ENOENT(self, unlink):
     exc = OSError()
     exc.errno = errno.ENOENT
     unlink.side_effect = exc
     p = PIDFile('/var/pid')
     p.remove()
     unlink.assert_called_with(p.path)
示例#5
0
 def test_remove_OSError(self, unlink):
     exc = OSError()
     exc.errno = errno.EAGAIN
     unlink.side_effect = exc
     p = PIDFile("/var/pid")
     with self.assertRaises(OSError):
         p.remove()
     unlink.assert_called_with(p.path)
示例#6
0
 def test_remove_OSError(self, unlink):
     exc = OSError()
     exc.errno = errno.EAGAIN
     unlink.side_effect = exc
     p = PIDFile('/var/pid')
     with self.assertRaises(OSError):
         p.remove()
     unlink.assert_called_with(p.path)
示例#7
0
        def test_remove_if_stale_no_pidfile(self):
            p = PIDFile("/var/pid")
            p.read_pid = Mock()
            p.read_pid.return_value = None
            p.remove = Mock()

            self.assertTrue(p.remove_if_stale())
            p.remove.assert_called_with()
示例#8
0
        def test_remove_if_stale_no_pidfile(self):
            p = PIDFile('/var/pid')
            p.read_pid = Mock()
            p.read_pid.return_value = None
            p.remove = Mock()

            self.assertTrue(p.remove_if_stale())
            p.remove.assert_called_with()
示例#9
0
        def test_remove_if_stale_broken_pid(self):
            with override_stdouts():
                p = PIDFile("/var/pid")
                p.read_pid = Mock()
                p.read_pid.side_effect = ValueError()
                p.remove = Mock()

                self.assertTrue(p.remove_if_stale())
                p.remove.assert_called_with()
示例#10
0
        def test_context(self):
            p = PIDFile("/var/pid")
            p.write_pid = Mock()
            p.remove = Mock()

            with p as _p:
                self.assertIs(_p, p)
            p.write_pid.assert_called_with()
            p.remove.assert_called_with()
示例#11
0
        def test_remove_if_stale_broken_pid(self):
            with override_stdouts():
                p = PIDFile('/var/pid')
                p.read_pid = Mock()
                p.read_pid.side_effect = ValueError()
                p.remove = Mock()

                self.assertTrue(p.remove_if_stale())
                p.remove.assert_called_with()
示例#12
0
        def test_context(self):
            p = PIDFile('/var/pid')
            p.write_pid = Mock()
            p.remove = Mock()

            with p as _p:
                self.assertIs(_p, p)
            p.write_pid.assert_called_with()
            p.remove.assert_called_with()
示例#13
0
 def test_remove_if_stale_process_dead(self, kill):
     with override_stdouts():
         p = PIDFile("/var/pid")
         p.read_pid = Mock()
         p.read_pid.return_value = 1816
         p.remove = Mock()
         exc = OSError()
         exc.errno = errno.ESRCH
         kill.side_effect = exc
         self.assertTrue(p.remove_if_stale())
         kill.assert_called_with(1816, 0)
         p.remove.assert_called_with()
示例#14
0
 def test_remove_if_stale_process_dead(self, kill):
     with override_stdouts():
         p = PIDFile('/var/pid')
         p.read_pid = Mock()
         p.read_pid.return_value = 1816
         p.remove = Mock()
         exc = OSError()
         exc.errno = errno.ESRCH
         kill.side_effect = exc
         self.assertTrue(p.remove_if_stale())
         kill.assert_called_with(1816, 0)
         p.remove.assert_called_with()
示例#15
0
 def test_remove(self, unlink):
     unlink.return_value = True
     p = PIDFile("/var/pid")
     p.remove()
     unlink.assert_called_with(p.path)
示例#16
0
 def test_remove(self, unlink):
     unlink.return_value = True
     p = PIDFile('/var/pid')
     p.remove()
     unlink.assert_called_with(p.path)