Example #1
0
  def test_get_uid(self):
    """
    Checks that stem.util.proc.get_uid matches our tor instance's uid.
    """

    if not proc.is_available():
      test.runner.skip(self, "(proc unavailable)")
      return

    tor_pid = test.runner.get_runner().get_pid()
    self.assertEquals(os.geteuid(), proc.get_uid(tor_pid))
Example #2
0
    def test_get_uid(self):
        """
    Checks that stem.util.proc.get_uid matches our tor instance's uid.
    """

        if not proc.is_available():
            test.runner.skip(self, "(proc unavailable)")
            return

        tor_pid = test.runner.get_runner().get_pid()
        self.assertEquals(os.geteuid(), proc.get_uid(tor_pid))
Example #3
0
  def test_get_uid(self):
    """
    Tests the get_uid function with a given pid.
    """

    for test_value in [(24019, 11111), (0, 22222)]:
      pid, uid = test_value
      mocking.mock(proc._get_line, mocking.return_for_args({
        ("/proc/%s/status" % pid, 'Uid:', 'uid'): 'Uid: %s' % uid
      }))

      self.assertEquals(uid, proc.get_uid(pid))
Example #4
0
File: proc.py Project: ouzel/stem
  def test_get_uid(self, get_line_mock):
    """
    Tests the get_uid function with a given pid.
    """

    for test_value in [(24019, 11111), (0, 22222)]:
      pid, uid = test_value

      get_line_mock.side_effect = lambda *params: {
        ("/proc/%s/status" % pid, 'Uid:', 'uid'): 'Uid: %s' % uid,
      }[params]

      self.assertEquals(uid, proc.get_uid(pid))
Example #5
0
    def test_get_uid(self, get_line_mock):
        """
    Tests the get_uid function with a given pid.
    """

        for test_value in [(24019, 11111), (0, 22222)]:
            pid, uid = test_value

            get_line_mock.side_effect = lambda *params: {
                ('/proc/%s/status' % pid, 'Uid:', 'uid'): 'Uid: %s' % uid,
            }[params]

            self.assertEquals(uid, proc.get_uid(pid))