示例#1
0
    def test_kill_processes_os_error(self):
        def side_effect(*args, **kwargs):
            raise OSError(errno.EPERM, "access denied")

        with contextlib.nested(
                self.mock_method('%s.pid.os.kill' % __name__, None, side_effect),
                self.mock_method('%s.pid.is_process_alive' % __name__, True, None)
        ):
            # This will fail with access denied, we can kill the
            # process.
            pids = [1, 2, 3, 4, 5]
            T.assert_raises(OSError, pid.kill_processes, pids)
示例#2
0
    def test_kill_processes_os_error(self):
        def side_effect(*args, **kwargs):
            raise OSError(errno.EPERM, "access denied")

        with contextlib.nested(
                self.mock_method('%s.pid.os.kill' % __name__, None,
                                 side_effect),
                self.mock_method('%s.pid.is_process_alive' % __name__, True,
                                 None)):
            # This will fail with access denied, we can kill the
            # process.
            pids = [1, 2, 3, 4, 5]
            T.assert_raises(OSError, pid.kill_processes, pids)
示例#3
0
 def test_tags_contains(self):
     T.assert_raises(TypeError, tags_contain, "A,B,C", None)
     T.assert_raises(AttributeError, tags_contain, None, [])
     T.assert_raises(AttributeError, tags_contain, None, None)
     T.assert_equal(tags_contain("", []), False)
     T.assert_equal(tags_contain("A,B,C", []), False)
     T.assert_equal(tags_contain("A,B,C", ["D"]), False)
     T.assert_equal(tags_contain("A", ["A"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A"]), True)
     T.assert_equal(tags_contain("A,B,C", ["B"]), True)
     T.assert_equal(tags_contain("A,B,C", ["C"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A", "C"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A", "B"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A", "B", "C"]), True)
示例#4
0
 def test_tags_contains(self):
     T.assert_raises(TypeError, tags_contain, "A,B,C", None)
     T.assert_raises(AttributeError, tags_contain, None, [])
     T.assert_raises(AttributeError, tags_contain, None, None)
     T.assert_equal(tags_contain("", []), False)
     T.assert_equal(tags_contain("A,B,C", []), False)
     T.assert_equal(tags_contain("A,B,C", ["D"]), False)
     T.assert_equal(tags_contain("A", ["A"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A"]), True)
     T.assert_equal(tags_contain("A,B,C", ["B"]), True)
     T.assert_equal(tags_contain("A,B,C", ["C"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A", "C"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A", "B"]), True)
     T.assert_equal(tags_contain("A,B,C", ["A", "B", "C"]), True)