示例#1
0
    def test_path_exists(self):
        fs = Filesystem()

        with patch.object(fs, 'exists'):
            with no_handlers_for_logger('mrjob.fs.base'):
                fs.path_exists('foo')

            fs.exists.assert_called_once_with('foo')
示例#2
0
    def test_path_join(self):
        fs = Filesystem()

        with patch.object(fs, 'join'):
            with no_handlers_for_logger('mrjob.fs.base'):
                fs.path_join('foo', 'bar')

            fs.join.assert_called_once_with('foo', 'bar')
示例#3
0
    def setUp(self):
        super(JoinTestCase, self).setUp()

        # os.path.join() and posixpath.join() do the same thing in
        # UNIX and OS X, so track which one we called
        self.start(patch('os.path.join', wraps=os.path.join))
        self.start(patch('posixpath.join', wraps=posixpath.join))

        self.fs = Filesystem()
示例#4
0
    def test_multiple_files(self):
        fs = Filesystem()

        fs.ls = Mock(return_value=['path1', 'path2', 'path3'])
        fs._cat_file = Mock(return_value=[b'chunk1\n', b'chunk2'])

        chunks = list(fs.cat('whatever'))

        self.assertEqual(chunks, [
            b'chunk1\n', b'chunk2', b'', b'chunk1\n', b'chunk2', b'',
            b'chunk1\n', b'chunk2'
        ])
示例#5
0
    def setUp(self):
        super(JoinTestCase, self).setUp()

        self.fs = Filesystem()