summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-02-23 22:12:24 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-02-23 22:12:24 (GMT)
commit71b13e8b4c4aad547d870a63e9b2f8784835eb2f (patch)
treeffd86a59998001499d1205ec4547a49d4465e865 /Lib
parentc3bbeb3749d84809e4b959788b7ff5f134f39ba3 (diff)
downloadcpython-71b13e8b4c4aad547d870a63e9b2f8784835eb2f.zip
cpython-71b13e8b4c4aad547d870a63e9b2f8784835eb2f.tar.gz
cpython-71b13e8b4c4aad547d870a63e9b2f8784835eb2f.tar.bz2
Fix SF bug #690081, test_posix fails when run in non-interactive mode
Don't bother testing os.getlogin() if we aren't running from a tty (terminal) It fails when run without a tty (e.g., when run from cron).
Diffstat (limited to 'Lib')
-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 4f0d5be..feb033d 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: