def test_setup_with_text(self): """Exercise bot with a -text argument.""" bot = AddTextBot(text='hello\\nworld') # setup unescapes any newlines self.assertEqual('hello\\nworld', bot.opt.text) bot.setup() self.assertEqual('hello\nworld', bot.opt.text)
def test_setup_with_textfile(self, mock_file): """Exercise both with a -textfile argument.""" bot = AddTextBot(textfile='/path/to/my/file.txt') # setup reads the file content self.assertEqual('', bot.opt.text) bot.setup() self.assertEqual('file data', bot.opt.text) mock_file.assert_called_with('/path/to/my/file.txt', 'rb', ANY)