コード例 #1
0
ファイル: test_util.py プロジェクト: ElDeveloper/biolopy
    def check_open_file_gc_behaviour(self, file, **kwargs):
        def mangle(file):
            with open_file(file, **kwargs) as result:
                self.assertIsInstance(result, io.TextIOBase)

        with open_file(file, encoding='binary') as f:
            mangle(f)
            self.assertFalse(f.closed)
コード例 #2
0
ファイル: test_util.py プロジェクト: zengqingsong/scikit-bio
    def check_open_file_gc_behaviour(self, file, **kwargs):
        def mangle(file):
            with open_file(file, **kwargs) as result:
                self.assertIsInstance(result, io.TextIOBase)

        with open_file(file, encoding='binary') as f:
            mangle(f)
            self.assertFalse(f.closed)
コード例 #3
0
ファイル: test_util.py プロジェクト: ElDeveloper/biolopy
    def check_open_file_state_contents(self, file, contents, is_binary,
                                       **kwargs):
        with open_file(file, **kwargs) as f:
            if is_binary:
                self.assertIsInstance(f, (io.BufferedReader,
                                          io.BufferedRandom))
            else:
                self.assertIsInstance(f, io.TextIOBase)
            self.assertTrue(f.readable())
            self.assertEqual(f.read(), contents)
        self.assertEqual(f.closed, self.expected_close)

        f.close()
        self.assertTrue(f.closed)
        self.check_closed(file, True)
コード例 #4
0
ファイル: test_util.py プロジェクト: zengqingsong/scikit-bio
    def check_open_file_state_contents(self, file, contents, is_binary,
                                       **kwargs):
        with open_file(file, **kwargs) as f:
            if is_binary:
                self.assertIsInstance(f, (io.BufferedReader,
                                          io.BufferedRandom))
            else:
                self.assertIsInstance(f, io.TextIOBase)
            self.assertTrue(f.readable())
            self.assertEqual(f.read(), contents)
        self.assertEqual(f.closed, self.expected_close)

        f.close()
        self.assertTrue(f.closed)
        self.check_closed(file, True)
コード例 #5
0
ファイル: test_util.py プロジェクト: ElDeveloper/biolopy
 def check_open_file_buffer_close_behaviour(self, file, **kwargs):
     if hasattr(file, 'close'):
         with open_file(file, **kwargs) as wrapped:
             file.close()
             self.assertTrue(wrapped.closed)
コード例 #6
0
ファイル: test_util.py プロジェクト: ElDeveloper/biolopy
 def mangle(file):
     with open_file(file, **kwargs) as result:
         self.assertIsInstance(result, io.TextIOBase)
コード例 #7
0
ファイル: test_util.py プロジェクト: zengqingsong/scikit-bio
 def check_open_file_buffer_close_behaviour(self, file, **kwargs):
     if hasattr(file, 'close'):
         with open_file(file, **kwargs) as wrapped:
             file.close()
             self.assertTrue(wrapped.closed)
コード例 #8
0
ファイル: test_util.py プロジェクト: zengqingsong/scikit-bio
 def mangle(file):
     with open_file(file, **kwargs) as result:
         self.assertIsInstance(result, io.TextIOBase)