Example #1
0
    def test_write_options_inplace0(self):
        '''write contents with options: in_place[0]'''

        self.mock_parameters.in_place = ''

        write_file('/tmp/pclean.test', self.contents)

        self.mock_open.assert_called_once_with('/tmp/pclean.test', 'w')
Example #2
0
    def test_write_options_none(self):
        '''write contents with options: none'''

        self.mock_parameters.in_place = None

        write_file('/tmp/pclean.test', self.contents)

        self.assertFalse(self.mock_open.called)
Example #3
0
    def test_write_options_inplace1(self):
        '''write contents with options: in_place[1]'''

        self.mock_parameters.in_place = '.bak'

        with mock.patch('pclean.os.rename') as mock_rename:
            write_file('/tmp/pclean.test', self.contents)

            mock_rename.assert_called_once_with('/tmp/pclean.test', '/tmp/pclean.test.bak')

        self.mock_open.assert_called_once_with('/tmp/pclean.test', 'w')