Пример #1
0
 def test_proc_cmdline(self):
     create_exe(self.funky_name)
     subp = get_test_subprocess(cmd=[self.funky_name])
     p = psutil.Process(subp.pid)
     cmdline = p.cmdline()
     if self.expect_exact_path_match():
         self.assertEqual(cmdline, [self.funky_name])
Пример #2
0
 def test_proc_exe(self):
     create_exe(self.funky_name)
     subp = get_test_subprocess(cmd=[self.funky_name])
     p = psutil.Process(subp.pid)
     exe = p.exe()
     self.assertIsInstance(exe, str)
     if self.expect_exact_path_match():
         self.assertEqual(exe, self.funky_name)
Пример #3
0
 def test_proc_exe(self):
     create_exe(self.funky_name)
     subp = get_test_subprocess(cmd=[self.funky_name])
     p = psutil.Process(subp.pid)
     exe = p.exe()
     self.assertIsInstance(exe, str)
     if self.expect_exact_path_match():
         self.assertEqual(exe, self.funky_name)
Пример #4
0
 def test_proc_cmdline(self):
     create_exe(self.funky_name)
     subp = get_test_subprocess(cmd=[self.funky_name])
     p = psutil.Process(subp.pid)
     cmdline = p.cmdline()
     for part in cmdline:
         self.assertIsInstance(part, str)
     if self.expect_exact_path_match():
         self.assertEqual(cmdline, [self.funky_name])
Пример #5
0
 def test_proc_name(self):
     create_exe(self.funky_name)
     subp = get_test_subprocess(cmd=[self.funky_name])
     if WINDOWS:
         # On Windows name() is determined from exe() first, because
         # it's faster; we want to overcome the internal optimization
         # and test name() instead of exe().
         from psutil._pswindows import py2_strencode
         name = py2_strencode(psutil._psplatform.cext.proc_name(subp.pid))
     else:
         name = psutil.Process(subp.pid).name()
     self.assertIsInstance(name, str)
     if self.expect_exact_path_match():
         self.assertEqual(name, os.path.basename(self.funky_name))
Пример #6
0
def subprocess_supports_unicode(name):
    """Return True if both the fs and the subprocess module can
    deal with a unicode file name.
    """
    if PY3:
        return True
    try:
        safe_rmpath(name)
        create_exe(name)
        get_test_subprocess(cmd=[name])
    except UnicodeEncodeError:
        return False
    else:
        reap_children()
        return True
Пример #7
0
def subprocess_supports_unicode(name):
    """Return True if both the fs and the subprocess module can
    deal with a unicode file name.
    """
    if PY3:
        return True
    try:
        safe_rmpath(name)
        create_exe(name)
        get_test_subprocess(cmd=[name])
    except UnicodeEncodeError:
        return False
    else:
        reap_children()
        return True
Пример #8
0
 def test_proc_name(self):
     create_exe(self.funky_name)
     subp = get_test_subprocess(cmd=[self.funky_name])
     if WINDOWS:
         # On Windows name() is determined from exe() first, because
         # it's faster; we want to overcome the internal optimization
         # and test name() instead of exe().
         with mock.patch("psutil._psplatform.cext.proc_exe",
                         side_effect=psutil.AccessDenied(os.getpid())) as m:
             name = psutil.Process(subp.pid).name()
             assert m.called
     else:
         name = psutil.Process(subp.pid).name()
     self.assertIsInstance(name, str)
     if self.expect_exact_path_match():
         self.assertEqual(name, os.path.basename(self.funky_name))
Пример #9
0
 def test_proc_name(self):
     create_exe(self.funky_name)
     subp = get_test_subprocess(cmd=[self.funky_name])
     if WINDOWS:
         # On Windows name() is determined from exe() first, because
         # it's faster; we want to overcome the internal optimization
         # and test name() instead of exe().
         with mock.patch("psutil._psplatform.cext.proc_exe",
                         side_effect=psutil.AccessDenied(os.getpid())) as m:
             name = psutil.Process(subp.pid).name()
             assert m.called
     else:
         name = psutil.Process(subp.pid).name()
     self.assertIsInstance(name, str)
     if self.expect_exact_path_match():
         self.assertEqual(name, os.path.basename(self.funky_name))
Пример #10
0
def subprocess_supports_unicode(suffix):
    """Return True if both the fs and the subprocess module can
    deal with a unicode file name.
    """
    if PY3:
        return True
    name = get_testfn(suffix=suffix)
    sproc = None
    try:
        safe_rmpath(name)
        create_exe(name)
        sproc = get_test_subprocess(cmd=[name])
    except UnicodeEncodeError:
        return False
    else:
        return True
    finally:
        if sproc is not None:
            terminate(sproc)
Пример #11
0
def try_unicode(suffix):
    """Return True if both the fs and the subprocess module can
    deal with a unicode file name.
    """
    sproc = None
    testfn = get_testfn(suffix=suffix)
    try:
        safe_rmpath(testfn)
        create_exe(testfn)
        sproc = spawn_testproc(cmd=[testfn])
        shutil.copyfile(testfn, testfn + '-2')
        safe_rmpath(testfn + '-2')
    except (UnicodeEncodeError, IOError):
        return False
    else:
        return True
    finally:
        if sproc is not None:
            terminate(sproc)
        safe_rmpath(testfn)
Пример #12
0
 def setUpClass(cls):
     safe_rmpath(cls.funky_name)
     create_exe(cls.funky_name)
Пример #13
0
 def setUpClass(cls):
     cls.funky_name = get_testfn(suffix=cls.funky_suffix)
     create_exe(cls.funky_name)
Пример #14
0
 def setUpClass(cls):
     safe_rmpath(cls.funky_name)
     create_exe(cls.funky_name)