'Assert that calling attach_pipeline after initialize raises correctly.'

def test_attach_pipeline_after_initialize(self):

    def initialize(context):
        pass
    def late_attach(context, data):
        attach_pipeline(Pipeline(), 'test')
        raise AssertionError("Shouldn't    make    it    past    attach_pipeline!")
    algo = TradingAlgorithm(initialize=initialize, handle_data=late_attach, data_frequency='daily', get_pipeline_loader=(lambda column: self.pipeline_loader), start=(self.first_asset_start - self.trading_day), end=(self.last_asset_end + self.trading_day), env=self.env)
    with self.assertRaises(AttachPipelineAfterInitialize):
        algo.run(self.data_portal)
    def barf(context, data):
        raise AssertionError("Shouldn't    make    it    past    before_trading_start")
    algo = TradingAlgorithm(initialize=initialize, before_trading_start=late_attach, handle_data=barf, data_frequency='daily', get_pipeline_loader=(lambda column: self.pipeline_loader), start=(self.first_asset_start - self.trading_day), end=(self.last_asset_end + self.trading_day), env=self.env)
    with self.assertRaises(AttachPipelineAfterInitialize):
        algo.run(self.data_portal)
