コード例 #1
0
    def test_file_is_used_directly_when_opened_file_is_given(self):
        file = mock.Mock()

        f = File(file)
        f.read()

        file.read.assert_called_once_with()
コード例 #2
0
ファイル: file_tests.py プロジェクト: hugsy/retdec-python
    def test_file_is_used_directly_when_opened_file_is_given(self):
        file = mock.Mock()

        f = File(file)
        f.read()

        file.read.assert_called_once_with()
コード例 #3
0
ファイル: file_tests.py プロジェクト: fangbei/retdec-python
 def test_file_is_opened_when_path_is_given(self, open):
     file = mock.Mock()
     open.return_value = file
     f = File('test.txt')
     f.read()
     open.assert_called_once_with('test.txt', 'rb')
     file.read.assert_called_once_with()
コード例 #4
0
 def test_file_is_opened_when_path_is_given(self, open):
     file = mock.Mock()
     open.return_value = file
     f = File('test.txt')
     f.read()
     open.assert_called_once_with('test.txt', 'rb')
     file.read.assert_called_once_with()
コード例 #5
0
    def test_mode_returns_original_mode_when_underlying_file_has_mode(self):
        file = mock.Mock()
        file.mode = 'r+'

        f = File(file)

        self.assertEqual(f.mode, 'r+')
コード例 #6
0
    def test_name_returns_original_name_when_no_custom_name_is_given(self):
        file = mock.Mock()
        file.name = 'file.txt'

        f = File(file)

        self.assertEqual(f.name, 'file.txt')
コード例 #7
0
ファイル: conn.py プロジェクト: fangbei/retdec-python
    def get_file(self, path='', params=None):
        """GETs a file from the given path with the given parameters.

        :param str path: Path to which the request should be sent.
        :param dict params: Request parameters.

        :returns: File from `path` (:class:`~retdec.file.File`).

        If `path` is the empty string, it sends the request to the base URL
        from which the connection was initialized.
        """
        response = self._send_request('get', path, params=params, stream=True)
        return File(response.raw, self._get_file_name(response.headers))
コード例 #8
0
ファイル: fileinfo.py プロジェクト: fangbei/retdec-python
 def _get_input_file(self, params):
     """Returns an input file from the given parameters (``dict``)."""
     if 'input_file' in params:
         return File(params['input_file'])
コード例 #9
0
 def _add_pdb_file_when_given(self, files, kwargs):
     """Adds a PDB file to `files` when it was given."""
     pdb_file = kwargs.get('pdb_file')
     if pdb_file is not None:
         files['pdb'] = File(pdb_file)
コード例 #10
0
 def _get_input_file(self, kwargs):
     """Returns the input file to be decompiled."""
     try:
         return File(kwargs['input_file'])
     except KeyError:
         raise MissingParameterError('input_file')
コード例 #11
0
    def test_repr_returns_correct_value(self):
        f = File(io.StringIO('...'), name='file.txt')

        self.assertEqual(repr(f), "<retdec.file.File name='file.txt' mode=None>")
コード例 #12
0
    def test_mode_returns_none_when_underlying_file_has_no_mode(self):
        f = File(io.StringIO('...'))

        self.assertIsNone(f.mode)
コード例 #13
0
    def test_name_returns_none_when_file_has_no_name(self):
        f = File(io.StringIO('...'))

        self.assertIsNone(f.name)
コード例 #14
0
    def test_name_returns_custom_name_when_given(self):
        f = File(io.StringIO('...'), 'file.txt')

        self.assertEqual(f.name, 'file.txt')