Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SunOS] saved=None confuses TestFetchAllProcesses.test_all #2358

Open
mtelka opened this issue Jan 22, 2024 · 0 comments
Open

[SunOS] saved=None confuses TestFetchAllProcesses.test_all #2358

mtelka opened this issue Jan 22, 2024 · 0 comments

Comments

@mtelka
Copy link
Contributor

mtelka commented Jan 22, 2024

Summary

  • OS: OpenIndiana
  • Architecture: 64bit
  • Psutil version: 5.9.8
  • Python version: 3.9.16
  • Type: core, tests

Description

Both Process.uids() and Process.gids() can return saved = None, but this makes the TestFetchAllProcesses.test_all test to fail with errors like:

________________________ TestFetchAllProcesses.test_all ________________________

self = <psutil.tests.test_process_all.TestFetchAllProcesses testMethod=test_all>

    def test_all(self):
        failures = []
        for info in self.iter_proc_info():
            for name, value in info.items():
                meth = getattr(self, name)
                try:
                    meth(value, info)
                except Exception:  # noqa: BLE001
                    s = '\n' + '=' * 70 + '\n'
                    s += "FAIL: name=test_%s, pid=%s, ret=%s\ninfo=%s\n" % (
                        name,
                        info['pid'],
                        repr(value),
                        info,
                    )
                    s += '-' * 70
                    s += "\n%s" % traceback.format_exc()
                    s = "\n".join((" " * 4) + i for i in s.splitlines()) + "\n"
                    failures.append(s)
                else:
                    if value not in (0, 0.0, [], None, '', {}):
                        assert value, value
        if failures:
>           raise self.fail(''.join(failures))
E           AssertionError:
E               ======================================================================
E               FAIL: name=test_gids, pid=0, ret=puids(real=0, effective=0, saved=None)
E               info={'pid': 0, 'exe': '', 'num_threads': 1, 'memory_full_info': pmem(rss=0, vms=0), 'gids': puids(real=0, effective=0, saved=None), 'cpu_num': 1, 'name': 'sched', 'create_time': 1705580724.5222604, 'memory_info': pmem(rss=0, vms=0), 'username': 'root', 'nice': 0, 'uids': puids(real=0, effective=0, saved=None), 'num_ctx_switches': pctxsw(voluntary=477, involuntary=71), 'ppid': 0, 'status': 'stopped', 'cmdline': ['sched']}
E               ----------------------------------------------------------------------
E               Traceback (most recent call last):
E                 File "/usr/lib/python3.9/vendor-packages/psutil/tests/test_process_all.py", line 135, in test_all
E                   meth(value, info)
E                 File "/usr/lib/python3.9/vendor-packages/psutil/tests/test_process_all.py", line 223, in gids
E                   self.assertIsInstance(gid, int)
E                 File "/usr/lib/python3.9/unittest/case.py", line 1260, in assertIsInstance
E                   self.fail(self._formatMessage(msg, standardMsg))
E                 File "/usr/lib/python3.9/unittest/case.py", line 676, in fail
E                   raise self.failureException(msg)
E               AssertionError: None is not an instance of <class 'int'>
E
E               ======================================================================
E               FAIL: name=test_uids, pid=0, ret=puids(real=0, effective=0, saved=None)
E               info={'pid': 0, 'exe': '', 'num_threads': 1, 'memory_full_info': pmem(rss=0, vms=0), 'gids': puids(real=0, effective=0, saved=None), 'cpu_num': 1, 'name': 'sched', 'create_time': 1705580724.5222604, 'memory_info': pmem(rss=0, vms=0), 'username': 'root', 'nice': 0, 'uids': puids(real=0, effective=0, saved=None), 'num_ctx_switches': pctxsw(voluntary=477, involuntary=71), 'ppid': 0, 'status': 'stopped', 'cmdline': ['sched']}
E               ----------------------------------------------------------------------
E               Traceback (most recent call last):
E                 File "/usr/lib/python3.9/vendor-packages/psutil/tests/test_process_all.py", line 135, in test_all
E                   meth(value, info)
E                 File "/usr/lib/python3.9/vendor-packages/psutil/tests/test_process_all.py", line 215, in uids
E                   self.assertIsInstance(uid, int)
E                 File "/usr/lib/python3.9/unittest/case.py", line 1260, in assertIsInstance
E                   self.fail(self._formatMessage(msg, standardMsg))
E                 File "/usr/lib/python3.9/unittest/case.py", line 676, in fail
E                   raise self.failureException(msg)
E               AssertionError: None is not an instance of <class 'int'>

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant