def test_kwarg_receives_argument(self): kwarg_qtask = _QTask(kwarg_task, None, None, None, None, another_parameter='Foo') self.input_q = multiprocessing.Queue() self.output_q = multiprocessing.Queue() kwarg_qtask.instantiate(self.input_q, self.output_q) self.input_q.put(['Bar']) kwarg_qtask.join() self.assertEqual([('Bar', 'Foo')], self.output_q.get())
def test_process_setup_and_teardown(self): global EXTERNAL_STORE self.assertDictEqual(EXTERNAL_STORE, {}) self.qtask = _QTask(do_something_external, None, None, setup_process, teardown_process) self.input_q = multiprocessing.Queue() self.output_q = multiprocessing.Queue() self.qtask.instantiate(self.input_q, self.output_q) self.input_q.put(["Hello",]) self.assertEqual(self.output_q.get(), ["Hello"]) # Processing should have finished, and the EXTERNAL STORE should therefore contain "Hello" in "sekrit"... # but in the other process, so we can't test it here. The teardown process DOES test it, though. self.qtask.join() # The teardown should have executed and we should have seen a total of one hello self.assertEqual(num_hellos.value, 1)
def test_creation_kwarg(self): kwarg_qtask = _QTask(kwarg_task, None, None, None, None, another_parameter='Foo') self.assertIsInstance(kwarg_qtask, _QTask)
def test_creation_with_callable(self, num=1, chunk_size=1): self.qtask = _QTask(null_task, num, chunk_size, None, None) self.assertIsInstance(self.qtask, _QTask)
def test_creation(self): null_qtask = _QTask(None, None, None, None, None) self.assertIsInstance(null_qtask, _QTask)