]> granicus.if.org Git - python/commitdiff
os.popen().close() returns None on success, not 0...
authorCharles-François Natali <neologix@free.fr>
Wed, 2 May 2012 18:50:13 +0000 (20:50 +0200)
committerCharles-François Natali <neologix@free.fr>
Wed, 2 May 2012 18:50:13 +0000 (20:50 +0200)
1  2 
Lib/test/test_posix.py

index 5ed2a0ffc514203cc27eaf73872d9ea644306983,c04c67921052b7aa977629108a4c2f1d433b7623..21473fc2eb2ab8eda6c1c102233dc10bd5a6e30d
@@@ -622,22 -421,6 +622,22 @@@ class PosixTester(unittest.TestCase)
                  os.chdir(curdir)
                  support.rmtree(base_path)
  
-         if ret != 0 or not groups:
 +    @unittest.skipUnless(hasattr(posix, 'getgrouplist'), "test needs posix.getgrouplist()")
 +    @unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()")
 +    @unittest.skipUnless(hasattr(os, 'getuid'), "test needs os.getuid()")
 +    def test_getgrouplist(self):
 +        with os.popen('id -G') as idg:
 +            groups = idg.read().strip()
 +            ret = idg.close()
 +
++        if ret != None or not groups:
 +            raise unittest.SkipTest("need working 'id -G'")
 +
 +        self.assertEqual(
 +            set([int(x) for x in groups.split()]),
 +            set(posix.getgrouplist(pwd.getpwuid(os.getuid())[0],
 +                pwd.getpwuid(os.getuid())[3])))
 +
      @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
      def test_getgroups(self):
          with os.popen('id -G') as idg: