# Buggy code
def init(self):
    if url_normalize is None:
        raise ValueError("Could not import 'url-normalize'. Please install it.")
    if get_tld is None:
        raise ValueError("Could not import 'tld'. Please install it.")
    update_tld_names()
    self.domain_whitelist = []
    if getattr(self.parameters, "domain_whitelist", "") != "":
        self.domain_whitelist.extend(self.parameters.domain_whitelist.split(","))
    self.substitutions = []
    if getattr(self.parameters, "substitutions", "") != "":
        temp = self.parameters.substitutions.split(";")
        if len(temp) % 2 != 0:
            raise InvalidArgument(
                "substitutions",
                got=self.parameters.substitutions,
                expected="even number of ; separeted strings",
            )
        for i in range(int(len(temp) / 2)):
            self.substitutions.append([temp[2 * i], temp[2 * i + 1]])
    self.classification_type = getattr(
        self.parameters, "classification_type", "unknown"
    )
    if not ClassificationType.is_valid(self.classification_type):
        self.classification_type = "unknown"


# Traceback (AssertionError)
INTELMQ_TEST_EXOTIC=1 nosetests tests/bots/parsers/twitter/test_parser.py
.F
======================================================================
FAIL: test_parse (intelmq.tests.bots.parsers.twitter.test_parser.TestTwitterParserBot)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/sebastian/dev/intelmq/intelmq/tests/bots/parsers/twitter/test_parser.py", line 71, in test_parse
self.assertMessageEqual(0, EVENTS[0])
File "/home/sebastian/dev/intelmq/intelmq/lib/test.py", line 481, in assertMessageEqual
self.assertDictEqual(expected, event_dict)
AssertionError: {'source.url': 'http://testweb.com/sales-in[486 chars]20K'} != {'feed.name': 'Twitter', 'feed.url': 'https[487 chars]ent'}
{'__type': 'Event',
'classification.type': 'blacklist',
'feed.name': 'Twitter',
'feed.url': 'https://twitter.com/El_carlos/1234456',
'raw': 'SGVyZSBpcyBteSBsaW5rLiBJIGhhdmUgcnVuIFNhbGVzLmV4ZSB3aXRoIFZNLgoKaHh4cDovL3Rlc3R3ZWJbLl1jb20vU2FsZXMtSW52b2ljZS8KY2MucHJvL2ltYWdlcy5odG1sClRoZXJlIGlzIGFub3RoZXIgdGhyZWF0LCBhbmQgdGhhdCBpcyBhdCAKaHR0cF1dOi8va2FybG9zIC5uZXQvCgp0YWsgYSBsb29rIGF0IGh4eHA6Ly9ibG9ja1suXWRlWy5dY29tL21hbHdhcmUuZXhlCkFub3RoZXIgdGhyZWF0IGlzIHBsYWNlZCBhdCAgZ2h6eixjb20K',
-  'source.url': 'http://testweb.com/sales-invoice/'}
+  'source.url': 'https://testweb.com/sales-invoice/'}
?                     +

-------------------- >> begin captured logging << --------------------
test-bot: INFO: TwitterParserBot initialized with id test-bot and intelmq 1.1.1.alpha1 and python 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC] as process 3356.
test-bot: INFO: Bot is starting.
test-bot: INFO: Processed 5 messages since last logging.
test-bot: INFO: Bot stopped.
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 2 tests in 0.041s

FAILED (failures=1)

# Fixed code
def init(self):
    if url_normalize is None:
        raise ValueError("Could not import 'url-normalize'. Please install it.")
    if tuple(int(v) for v in url_version.split(".")) < (1, 4, 1) and hasattr(
        self.parameters, "default_scheme"
    ):
        raise ValueError(
            "Parameter 'default_scheme' given but 'url-normalize' version %r does not support it. Get at least version '1.4.1'."
            % url_version
        )
    if get_tld is None:
        raise ValueError("Could not import 'tld'. Please install it.")
    try:
        update_tld_names()
    except tld.exceptions.TldIOError:
        self.logger.info("Could not update TLD names cache.")
    self.domain_whitelist = []
    if getattr(self.parameters, "domain_whitelist", "") != "":
        self.domain_whitelist.extend(self.parameters.domain_whitelist.split(","))
    self.substitutions = []
    if getattr(self.parameters, "substitutions", "") != "":
        temp = self.parameters.substitutions.split(";")
        if len(temp) % 2 != 0:
            raise InvalidArgument(
                "substitutions",
                got=self.parameters.substitutions,
                expected="even number of ; separeted strings",
            )
        for i in range(int(len(temp) / 2)):
            self.substitutions.append([temp[2 * i], temp[2 * i + 1]])
    self.classification_type = getattr(
        self.parameters, "classification_type", "unknown"
    )
    if not ClassificationType.is_valid(self.classification_type):
        self.classification_type = "unknown"

    if hasattr(self.parameters, "default_scheme"):
        self.url_kwargs = {"default_scheme": self.parameters.default_scheme}
    else:
        self.url_kwargs = {}