Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
test_File.AsHandleTestCase Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_handle
def test_path
def test_stringio

Public Attributes

 temp_dir

Private Member Functions

def _path

Detailed Description

Definition at line 68 of file test_File.py.


Member Function Documentation

def test_File.AsHandleTestCase._path (   self,
  args 
) [private]

Definition at line 77 of file test_File.py.

00077 
00078     def _path(self, *args):
00079         return os.path.join(self.temp_dir, *args)

Here is the caller graph for this function:

Definition at line 70 of file test_File.py.

00070 
00071     def setUp(self):
00072         # Create a directory to work in
00073         self.temp_dir = tempfile.mkdtemp(prefix='biopython-test')

Definition at line 74 of file test_File.py.

00074 
00075     def tearDown(self):
00076         shutil.rmtree(self.temp_dir)

Definition at line 80 of file test_File.py.

00080 
00081     def test_handle(self):
00082         "Test as_handle with a file-like object argument"
00083         p = self._path('test_file.fasta')
00084         with open(p, 'wb') as fp:
00085             with File.as_handle(fp) as handle:
00086                 self.assertEqual(fp, handle, "as_handle should "
00087                         "return argument when given a file-like object")
00088                 self.assertFalse(handle.closed)
00089 
00090             self.assertFalse(handle.closed,
00091                     "Exiting as_handle given a file-like object should not "
00092                     "close the file")

Here is the call graph for this function:

Definition at line 93 of file test_File.py.

00093 
00094     def test_path(self):
00095         "Test as_handle with a path argument"
00096         p = self._path('test_file.fasta')
00097         mode = 'wb'
00098         with File.as_handle(p, mode=mode) as handle:
00099             self.assertEqual(p, handle.name)
00100             self.assertEqual(mode, handle.mode)
00101             self.assertFalse(handle.closed)
00102         self.assertTrue(handle.closed)

Here is the call graph for this function:

Definition at line 103 of file test_File.py.

00103 
00104     def test_stringio(self):
00105         s = StringIO()
00106         with File.as_handle(s) as handle:
00107             self.assertEqual(s, handle)

Member Data Documentation

Definition at line 72 of file test_File.py.


The documentation for this class was generated from the following file: