#9808. Implement os.getlogin for Windows, completed by Jon Anglin.
The test is semi-dumb, it just makes sure something comes back since we
don't have a solid source to validate the returned login. We can't be 100%
sure that the USERNAME env var will always match what os.getlogin() returns,
so we don't make any specific assertion there.
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 12e516e..5509f1f 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -1202,6 +1202,13 @@
self.assertEqual(int(stdout), os.getpid())
+@unittest.skipUnless(hasattr(os, 'getlogin'), "test needs os.getlogin")
+class LoginTests(unittest.TestCase):
+ def test_getlogin(self):
+ user_name = os.getlogin()
+ self.assertNotEqual(len(user_name), 0)
+
+
def test_main():
support.run_unittest(
FileTests,
@@ -1220,6 +1227,7 @@
Win32SymlinkTests,
FSEncodingTests,
PidTests,
+ LoginTests,
)
if __name__ == "__main__":