def testTwitterFeed(self):
        events = {
            "on_tweet": False,
            "start": datetime.datetime.now()
        }
        disp = dispatcher.Dispatcher()

        def on_tweet(data):
            events["on_tweet"] = True
            disp.stop()

        def on_idle():
            # Stop after 5 minutes.
            if (events["start"] - datetime.datetime.now()).seconds > 60*5:
                disp.stop()

        # Create a twitter feed to track BitCoin related events.
        consumer_key = os.getenv("TWITTER_CONSUMER_KEY")
        consumer_secret = os.getenv("TWITTER_CONSUMER_SECRET")
        access_token = os.getenv("TWITTER_ACCESS_TOKEN")
        access_token_secret = os.getenv("TWITTER_ACCESS_TOKEN_SECRET")
        track = ["bitcoin", "btc"]
        follow = []
        languages = ["en"]
        twitterFeed = twitterfeed.TwitterFeed(
            consumer_key,
            consumer_secret,
            access_token,
            access_token_secret,
            track,
            follow,
            languages
        )

        disp.addSubject(twitterFeed)
        twitterFeed.subscribe(on_tweet)
        disp.getIdleEvent().subscribe(on_idle)
        disp.run()

        # Check that we received both events.
        self.assertTrue(events["on_tweet"])
dataset/ETHPy150Open gbeced/pyalgotrade/testcases/twitter_test.py/TwitterFeedTestCase.testTwitterFeed/swapped operands of `-`