def test_register_with_invalid_output_should_raise_valueerror(self): with self.assertRaises(ValueError): register_action( 'good-key', lambda _1, _2: True, output='unexpected', )
def setUp(self): register_action('final', lambda _1, _2: True, expected_input='stream') register_action('non-final', lambda _1, _2: True, expected_input='stream', output='stream') return super().setUp()
def test_register_with_a_non_callable_unaction_should_raise_typeerror(self): with self.assertRaises(TypeError): register_action( 'good-key', action=lambda _1, _2: True, unaction=[], output='directory', )
def test_register_correct_action_should_pass(self): register_action( 'ab', lambda _1, _2: None, lambda _1, _2: False, None, 'stream', )
def test_register_with_invalid_identifier_should_raise_keyerror(self): keys = ['a', '9-the-best', '(yes)', '_123-yes.'] for i, key in zip(range(len(keys)), keys): with self.subTest(i=i): with self.assertRaises(KeyError): register_action( key, lambda _1, _2: True, expected_input='stream', )
def test_register_with_duplicated_key_should_raise_keyerror(self): register_action( 'ab', lambda _1, _2: None, output='stream', ) with self.assertRaises(KeyError): register_action( 'ab', lambda _1, _2: True, expected_input='stream', )
def setUp(self): register_action( 'very-specific-action', action=lambda _1, _2: True, unaction=lambda _1, _2: 'yes', output='directory', ) register_action( 'very-specific-action-with-no-unaction', action=lambda _1, _2: True, output='directory', ) return super().setUp()
def _register_actions(this=None): if this is not None: this._initial_stream_mock = Mock(spec=FileIO) this._middle_stream_mock = Mock(spec=Popen) this._middle_stream_mock.stdout = MagicMock(spec=FileIO) this._middle_stream_mock.stderr = MagicMock(spec=FileIO) this._middle_stream_mock.wait.return_value = 0 register_action('initial', lambda _1, _2: this._initial_stream_mock, output='stream') register_action('middle', lambda _1, _2: this._middle_stream_mock, expected_input='stream', output='stream') else: register_action('initial', lambda _1, _2: None, output='stream') register_action('middle', lambda _1, _2: None, expected_input='stream', output='stream') register_action('final', lambda _1, _2: Path('final-file'), expected_input='stream') register_action('final-with-no-path', lambda _1, _2: None, expected_input='stream') register_action('ifailure', _failure_impl, output='stream') register_action('ffailure', _failure_impl, expected_input='stream') register_action('bad', lambda _1, _2: [], output='stream')
def setUp(self): register_action('very-specific-action', lambda _1, _2: True, output='directory') return super().setUp()
def setUpClass(cls): super().setUpClass() register_action('final-action', lambda: None, expected_input='stream') register_action('initial-action', lambda: None, output='stream')
def setUpClass(cls): super().setUpClass() register_action('test-action', lambda: None, expected_input='stream')
def test_register_with_a_non_callable_action_should_raise_typeerror(self): with self.assertRaises(TypeError): register_action('good-key', [], output='directory')
def test_register_without_expected_input_nor_output_should_work(self): register_action('good-key', lambda _1, _2: True)