psutil.tests.test_unicode

In psutil these are the APIs returning or dealing with a string (‘not tested’ means they are not tested to deal with non-ASCII strings):

  • Process.cmdline()
  • Process.connections(‘unix’)
  • Process.cwd()
  • Process.environ()
  • Process.exe()
  • Process.memory_maps()
  • Process.name()
  • Process.open_files()
  • Process.username() (not tested)
  • disk_io_counters() (not tested)
  • disk_partitions() (not tested)
  • disk_usage(str)
  • net_connections(‘unix’)
  • net_if_addrs() (not tested)
  • net_if_stats() (not tested)
  • net_io_counters() (not tested)
  • sensors_fans() (not tested)
  • sensors_temperatures() (not tested)
  • users() (not tested)
  • WindowsService.binpath() (not tested)
  • WindowsService.description() (not tested)
  • WindowsService.display_name() (not tested)
  • WindowsService.name() (not tested)
  • WindowsService.status() (not tested)
  • WindowsService.username() (not tested)

In here we create a unicode path with a funky non-ASCII name and (where possible) make psutil return it back (e.g. on name(), exe(), open_files(), etc.) and make sure that:

  • psutil never crashes with UnicodeDecodeError
  • the returned path matches

For a detailed explanation of how psutil handles unicode see: - https://github.com/giampaolo/psutil/issues/1040 - http://psutil.readthedocs.io/#unicode

Module Contents

safe_rmpath(path)
subprocess_supports_unicode(name)

Return True if both the fs and the subprocess module can deal with a unicode file name.

INVALID_NAME
class _BaseFSAPIsTests

Bases:object

funky_name
classmethod setUpClass(cls)
classmethod tearDownClass(cls)
tearDown(self)
expect_exact_path_match(self)
test_proc_exe(self)
test_proc_name(self)
test_proc_cmdline(self)
test_proc_cwd(self)
test_proc_open_files(self)
test_proc_connections(self)
test_net_connections(self)
test_disk_usage(self)
test_memory_maps(self)
class TestFSAPIs

Bases:psutil.tests.test_unicode._BaseFSAPIsTests, psutil.tests.unittest.TestCase

Test FS APIs with a funky, valid, UTF8 path name.

funky_name
classmethod expect_exact_path_match(cls)
class TestFSAPIsWithInvalidPath

Bases:psutil.tests.test_unicode._BaseFSAPIsTests, psutil.tests.unittest.TestCase

Test FS APIs with a funky, invalid path name.

funky_name
classmethod expect_exact_path_match(cls)
class TestWinProcessName

Bases:psutil.tests.unittest.TestCase

test_name_type(self)
class TestNonFSAPIS

Bases:psutil.tests.unittest.TestCase

Unicode tests for non fs-related APIs.

tearDown(self)
test_proc_environ(self)