]> granicus.if.org Git - python/commitdiff
#1087: use proper skips in test_os.
authorEzio Melotti <ezio.melotti@gmail.com>
Wed, 26 Sep 2012 17:01:34 +0000 (20:01 +0300)
committerEzio Melotti <ezio.melotti@gmail.com>
Wed, 26 Sep 2012 17:01:34 +0000 (20:01 +0300)
Lib/test/test_os.py

index 6219eff767297ae932808eaeef351606bc62798e..7d6b3779a42b6c78defcf2b450ec8b7cf1ea4bef 100644 (file)
@@ -514,23 +514,23 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
         return os.environ
 
     # Bug 1110478
+    @unittest.skipUnless(os.path.exists('/bin/sh'), 'requires /bin/sh')
     def test_update2(self):
         os.environ.clear()
-        if os.path.exists("/bin/sh"):
-            os.environ.update(HELLO="World")
-            with os.popen("/bin/sh -c 'echo $HELLO'") as popen:
-                value = popen.read().strip()
-                self.assertEqual(value, "World")
+        os.environ.update(HELLO="World")
+        with os.popen("/bin/sh -c 'echo $HELLO'") as popen:
+            value = popen.read().strip()
+            self.assertEqual(value, "World")
 
+    @unittest.skipUnless(os.path.exists('/bin/sh'), 'requires /bin/sh')
     def test_os_popen_iter(self):
-        if os.path.exists("/bin/sh"):
-            with os.popen(
-                "/bin/sh -c 'echo \"line1\nline2\nline3\"'") as popen:
-                it = iter(popen)
-                self.assertEqual(next(it), "line1\n")
-                self.assertEqual(next(it), "line2\n")
-                self.assertEqual(next(it), "line3\n")
-                self.assertRaises(StopIteration, next, it)
+        with os.popen(
+            "/bin/sh -c 'echo \"line1\nline2\nline3\"'") as popen:
+            it = iter(popen)
+            self.assertEqual(next(it), "line1\n")
+            self.assertEqual(next(it), "line2\n")
+            self.assertEqual(next(it), "line3\n")
+            self.assertRaises(StopIteration, next, it)
 
     # Verify environ keys and values from the OS are of the
     # correct str type.