summaryrefslogtreecommitdiff
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 4f0d5be4aa..feb033d54d 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -29,10 +29,17 @@ class PosixTester(unittest.TestCase):
# test posix functions which take no arguments and have
# no side-effects which we need to cleanup (e.g., fork, wait, abort)
NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdu", "uname",
- "times", "getlogin", "getloadavg", "tmpnam",
+ "times", "getloadavg", "tmpnam",
"getegid", "geteuid", "getgid", "getgroups",
"getpid", "getpgrp", "getppid", "getuid",
]
+ # getlogin() only works when run from a tty (terminal)
+ try:
+ if os.isatty(sys.stdin.fileno()):
+ NO_ARG_FUNCTIONS.append("getlogin")
+ except:
+ pass
+
for name in NO_ARG_FUNCTIONS:
posix_func = getattr(posix, name, None)
if posix_func is not None: