Fix test breakage due to change in calling order of AsynchronousTask start
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:22:20 +0000 (06:22 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:22:20 +0000 (06:22 -0000)
listeners from r12713. (trunk r12717)

svn path=/main/branches/2.1.6/; revision=12972

pym/portage/tests/process/test_poll.py

index ebcc822ef9a27a584c4309fa5ba311059395712e..9049304104ea061f40012009fabcf30888f5739a 100644 (file)
@@ -33,7 +33,13 @@ class PipeReaderTestCase(TestCase):
                task_scheduler = TaskScheduler(max_jobs=2)
                scheduler = task_scheduler.sched_iface
 
-               producer = SpawnProcess(
+               class Producer(SpawnProcess):
+                       def _spawn(self, args, **kwargs):
+                               rval = SpawnProcess._spawn(self, args, **kwargs)
+                               os.close(kwargs['fd_pipes'][1])
+                               return rval
+
+               producer = Producer(
                        args=["bash", "-c", "echo -n '%s'" % test_string],
                        fd_pipes={1:slave_fd}, scheduler=scheduler)
 
@@ -44,10 +50,6 @@ class PipeReaderTestCase(TestCase):
                task_scheduler.add(producer)
                task_scheduler.add(consumer)
 
-               def producer_start_cb(task):
-                       os.close(slave_fd)
-
-               producer.addStartListener(producer_start_cb)
                task_scheduler.run()
 
                self._assertEqual(test_string, consumer.getvalue())