diff options
-rw-r--r-- | Lib/test/support/__init__.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index d71cfe5..e5eb66e 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -5,6 +5,7 @@ if __name__ != 'test.support': import contextlib import functools +import getpass import os import re import stat @@ -378,10 +379,11 @@ def skip_if_buildbot(reason=None): """Decorator raising SkipTest if running on a buildbot.""" if not reason: reason = 'not suitable for buildbots' - if sys.platform == 'win32': - isbuildbot = os.environ.get('USERNAME') == 'Buildbot' - else: - isbuildbot = os.environ.get('USER') == 'buildbot' + try: + isbuildbot = getpass.getuser().lower() == 'buildbot' + except (KeyError, EnvironmentError) as err: + warnings.warn(f'getpass.getuser() failed {err}.', RuntimeWarning) + isbuildbot = False return unittest.skipIf(isbuildbot, reason) def check_sanitizer(*, address=False, memory=False, ub=False): |