import contextlib
import functools
+import getpass
import os
import re
import stat
"""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):