import unittest

import stdio
from ctypes import POINTER, c_int

class DynModTest(unittest.TestCase):
    def test_fopen(self):
        self.failUnlessEqual(stdio.fopen.restype, POINTER(stdio.FILE))
        self.failUnlessEqual(stdio.fopen.argtypes, [stdio.STRING, stdio.STRING])

    def test_constants(self):
        self.failUnlessEqual(stdio.O_RDONLY, 0)
        self.failUnlessEqual(stdio.O_WRONLY, 1)
        self.failUnlessEqual(stdio.O_RDWR, 2)

if __name__ == "__main__":
    unittest.main()

import unittest
import os, glob

import stdio
from ctypes import POINTER, c_int

class DynModTest(unittest.TestCase):
    def tearDown(self):
        for fnm in glob.glob(stdio._gen_basename + ".*"):
            try:
                os.remove(fnm)
            except IOError:
                pass

    def test_fopen(self):
        self.failUnlessEqual(stdio.fopen.restype, POINTER(stdio.FILE))
        self.failUnlessEqual(stdio.fopen.argtypes, [stdio.STRING, stdio.STRING])

    def test_constants(self):
        self.failUnlessEqual(stdio.O_RDONLY, 0)
        self.failUnlessEqual(stdio.O_WRONLY, 1)
        self.failUnlessEqual(stdio.O_RDWR, 2)

if __name__ == "__main__":
    unittest.main()

Clean up generated files in the tearDown method.
Clean up generated files in the tearDown method.

  import unittest
+ import os, glob
  
  import stdio
  from ctypes import POINTER, c_int
  
  class DynModTest(unittest.TestCase):
+     def tearDown(self):
+         for fnm in glob.glob(stdio._gen_basename + ".*"):
+             try:
+                 os.remove(fnm)
+             except IOError:
+                 pass
+ 
      def test_fopen(self):
          self.failUnlessEqual(stdio.fopen.restype, POINTER(stdio.FILE))
          self.failUnlessEqual(stdio.fopen.argtypes, [stdio.STRING, stdio.STRING])
  
      def test_constants(self):
          self.failUnlessEqual(stdio.O_RDONLY, 0)
          self.failUnlessEqual(stdio.O_WRONLY, 1)
          self.failUnlessEqual(stdio.O_RDWR, 2)
  
  if __name__ == "__main__":
      unittest.main()
  
Clean up generated files in the tearDown method.
## Code Before:
import unittest

import stdio
from ctypes import POINTER, c_int

class DynModTest(unittest.TestCase):
    def test_fopen(self):
        self.failUnlessEqual(stdio.fopen.restype, POINTER(stdio.FILE))
        self.failUnlessEqual(stdio.fopen.argtypes, [stdio.STRING, stdio.STRING])

    def test_constants(self):
        self.failUnlessEqual(stdio.O_RDONLY, 0)
        self.failUnlessEqual(stdio.O_WRONLY, 1)
        self.failUnlessEqual(stdio.O_RDWR, 2)

if __name__ == "__main__":
    unittest.main()

## Instruction:
Clean up generated files in the tearDown method.
## Code After:
import unittest
import os, glob

import stdio
from ctypes import POINTER, c_int

class DynModTest(unittest.TestCase):
    def tearDown(self):
        for fnm in glob.glob(stdio._gen_basename + ".*"):
            try:
                os.remove(fnm)
            except IOError:
                pass

    def test_fopen(self):
        self.failUnlessEqual(stdio.fopen.restype, POINTER(stdio.FILE))
        self.failUnlessEqual(stdio.fopen.argtypes, [stdio.STRING, stdio.STRING])

    def test_constants(self):
        self.failUnlessEqual(stdio.O_RDONLY, 0)
        self.failUnlessEqual(stdio.O_WRONLY, 1)
        self.failUnlessEqual(stdio.O_RDWR, 2)

if __name__ == "__main__":
    unittest.main()
