]> granicus.if.org Git - python/commitdiff
Add basic tests for the return value of os.popen().close().
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Sat, 11 Jul 2009 09:09:59 +0000 (09:09 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Sat, 11 Jul 2009 09:09:59 +0000 (09:09 +0000)
According to #6358, python 3.0 has a different implementation that behaves differently.

Lib/test/test_popen.py

index 069f370041d3179dbb1c0c27d58c6884b6d2e111..cb65fdf2fcde2a19c664876e37a8c550b3908608 100644 (file)
@@ -40,6 +40,13 @@ class PopenTest(unittest.TestCase):
         )
         test_support.reap_children()
 
+    def test_return_code(self):
+        self.assertEqual(os.popen("exit 0").close(), None)
+        if os.name == 'nt':
+            self.assertEqual(os.popen("exit 42").close(), 42)
+        else:
+            self.assertEqual(os.popen("exit 42").close(), 42 << 8)
+
 def test_main():
     test_support.run_unittest(PopenTest)