# Buggy code
def update_tracker_info(self, tracker_url, is_successful):
    """
    Updates a tracker information.
    :param tracker_url: The given tracker_url.
    :param is_successful: If the check was successful.
    """
    if tracker_url not in self._tracker_dict:
        self._logger.error(
            "Trying to update the tracker info of an unknown tracker URL"
        )
        return

    tracker_info = self._tracker_dict[tracker_url]

    current_time = int(time.time())
    failures = 0 if is_successful else tracker_info["failures"] + 1
    is_alive = tracker_info["failures"] < self._max_tracker_failures

    # update the dict
    tracker_info["last_check"] = current_time
    tracker_info["failures"] = failures
    tracker_info["is_alive"] = is_alive

    # update the database
    sql_stmt = "UPDATE TrackerInfo SET last_check = ?, failures = ?, is_alive = ? WHERE tracker_id = ?"
    value_tuple = (
        tracker_info["last_check"],
        tracker_info["failures"],
        tracker_info["is_alive"],
        tracker_info["id"],
    )
    self._session.sqlite_db.execute(sql_stmt, value_tuple)


# 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 update_tracker_info(self, tracker_url, is_successful):
    """
    Updates a tracker information.
    :param tracker_url: The given tracker_url.
    :param is_successful: If the check was successful.
    """
    sql_stmt = "SELECT tracker_id, tracker, last_check, failures, is_alive FROM TrackerInfo WHERE tracker = ?"
    try:
        self._session.sqlite_db.execute(sql_stmt, (tracker_url,)).next()
    except StopIteration:
        self._logger.error(
            "Trying to update the tracker info of an unknown tracker URL"
        )
        return

    tracker_info = self.get_tracker_info(tracker_url)

    current_time = int(time.time())
    failures = 0 if is_successful else tracker_info["failures"] + 1
    is_alive = tracker_info["failures"] < MAX_TRACKER_FAILURES

    # update the dict
    tracker_info["last_check"] = current_time
    tracker_info["failures"] = failures
    tracker_info["is_alive"] = is_alive

    # update the database
    sql_stmt = "UPDATE TrackerInfo SET last_check = ?, failures = ?, is_alive = ? WHERE tracker_id = ?"
    value_tuple = (
        tracker_info["last_check"],
        tracker_info["failures"],
        tracker_info["is_alive"],
        tracker_info["id"],
    )
    self._session.sqlite_db.execute(sql_stmt, value_tuple)