# Buggy code
def _task_select_tracker(self):
    """
    The regularly scheduled task that selects torrents associated with a specific tracker to check.
    """

    # update the torrent selection interval
    self._reschedule_tracker_select()

    # start selecting torrents
    result = self.tribler_session.lm.tracker_manager.get_next_tracker_for_auto_check()
    if result is None:
        self._logger.warn("No tracker to select from, skip")
        return succeed(None)

    tracker_url, _ = result
    self._logger.debug("Start selecting torrents on tracker %s.", tracker_url)

    # get the torrents that should be checked
    infohashes = self._torrent_db.getTorrentsOnTracker(tracker_url, int(time.time()))

    if len(infohashes) == 0:
        # We have not torrent to recheck for this tracker. Still update the last_check for this tracker.
        self._logger.info("No torrent to check for tracker %s", tracker_url)
        self.tribler_session.lm.tracker_manager.update_tracker_info(tracker_url, True)
        return succeed(None)
    elif (
        tracker_url != "DHT"
        and tracker_url != "no-DHT"
        and self.tribler_session.lm.tracker_manager.should_check_tracker(tracker_url)
    ):
        try:
            session = self._create_session_for_request(tracker_url, timeout=30)
        except MalformedTrackerURLException as e:
            self._logger.error(e)
            return succeed(None)

        for infohash in infohashes:
            session.add_infohash(infohash)

        self._logger.info(
            "Selected %d new torrents to check on tracker: %s",
            len(infohashes),
            tracker_url,
        )
        return (
            session.connect_to_tracker()
            .addCallbacks(*self.get_callbacks_for_session(session))
            .addErrback(lambda _: None)
        )


# Traceback (AssertionError)
Tuples differ: (2, ('127.0.0.1', [5, 4, 3, 2,... != (2, ('127.0.0.1', [5, 4, 3, 2,...

First differing element 2:
u'None'
''

- (2, ('127.0.0.1', [5, 4, 3, 2, 1]), u'None')
?                                     - ----

+ (2, ('127.0.0.1', [5, 4, 3, 2, 1]), '')
Stacktrace

Traceback (most recent call last):
File "c:\python27\lib\unittest\case.py", line 329, in run
testMethod()
File "C:\workspace\jenkins\workspace\GH_Tribler_PR_tests_win64\tribler\Tribler\Test\test_as_server.py", line 58, in check
result = fun(*argv, **kwargs)
File "C:\workspace\jenkins\workspace\GH_Tribler_PR_tests_win64\tribler\Tribler\Test\Core\Upgrade\test_config_upgrade_70_71.py", line 33, in test_read_test_libtribler_conf
self.assertEqual(result_config.get_anon_proxy_settings(), (2, ("127.0.0.1", [5, 4, 3, 2, 1]), ''))
File "c:\python27\lib\unittest\case.py", line 513, in assertEqual
assertion_func(first, second, msg=msg)
File "c:\python27\lib\unittest\case.py", line 753, in assertTupleEqual
self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
File "c:\python27\lib\unittest\case.py", line 724, in assertSequenceEqual
self.fail(msg)
File "c:\python27\lib\unittest\case.py", line 410, in fail
raise self.failureException(msg)
AssertionError: Tuples differ: (2, ('127.0.0.1', [5, 4, 3, 2,... != (2, ('127.0.0.1', [5, 4, 3, 2,...

First differing element 2:
u'None'
''

- (2, ('127.0.0.1', [5, 4, 3, 2, 1]), u'None')
?                                     - ----

+ (2, ('127.0.0.1', [5, 4, 3, 2, 1]), '')

# Fixed code
def _task_select_tracker(self):
    """
    The regularly scheduled task that selects torrents associated with a specific tracker to check.
    """

    # update the torrent selection interval
    self._reschedule_tracker_select()

    # start selecting torrents
    tracker_url = (
        self.tribler_session.lm.tracker_manager.get_next_tracker_for_auto_check()
    )
    if tracker_url is None:
        self._logger.warn("No tracker to select from, skip")
        return succeed(None)

    self._logger.debug("Start selecting torrents on tracker %s.", tracker_url)

    # get the torrents that should be checked
    infohashes = self._torrent_db.getTorrentsOnTracker(tracker_url, int(time.time()))

    if len(infohashes) == 0:
        # We have not torrent to recheck for this tracker. Still update the last_check for this tracker.
        self._logger.info("No torrent to check for tracker %s", tracker_url)
        self.tribler_session.lm.tracker_manager.update_tracker_info(tracker_url, True)
        return succeed(None)
    elif tracker_url != "DHT" and tracker_url != "no-DHT":
        try:
            session = self._create_session_for_request(tracker_url, timeout=30)
        except MalformedTrackerURLException as e:
            self._logger.error(e)
            return succeed(None)

        for infohash in infohashes:
            session.add_infohash(infohash)

        self._logger.info(
            "Selected %d new torrents to check on tracker: %s",
            len(infohashes),
            tracker_url,
        )
        return (
            session.connect_to_tracker()
            .addCallbacks(*self.get_callbacks_for_session(session))
            .addErrback(lambda _: None)
        )