<commit_before>import unittest

from urlobject import URLObject


class URLObjectTest(unittest.TestCase):

    def setUp(self):
        self.url_string = u"https://github.com/zacharyvoase/urlobject?spam=eggs#foo"

    def test_urlobject_preserves_equality_with_the_original_string(self):
        assert URLObject(self.url_string) == self.url_string

    def test_urlobject_preserves_the_hash_of_the_original_string(self):
        assert hash(URLObject(self.url_string)) == hash(self.url_string)

    def test_calling_unicode_on_a_urlobject_returns_a_normal_string(self):
        url = URLObject(self.url_string)
        # Normally `type(x) is Y` is a bad idea, but it's exactly what we want.
        assert type(unicode(url)) is unicode
        assert unicode(url) == self.url_string


class URLObjectPropertyTest(unittest.TestCase):

    def setUp(self):
        self.url = URLObject(u"https://github.com/zacharyvoase/urlobject?spam=eggs#foo")

    def test_scheme_returns_scheme(self):
        assert self.url.scheme == u'https'

    def test_netloc_returns_netloc(self):
        assert self.url.netloc == u'github.com'

    def test_port_returns_port_or_None(self):
        assert self.url.port is None
        assert URLObject("https://github.com:412").port == 412<commit_msg>Added a unit test for the hostname property.<commit_after>import unittest

from urlobject import URLObject


class URLObjectTest(unittest.TestCase):

    def setUp(self):
        self.url_string = u"https://github.com/zacharyvoase/urlobject?spam=eggs#foo"

    def test_urlobject_preserves_equality_with_the_original_string(self):
        assert URLObject(self.url_string) == self.url_string

    def test_urlobject_preserves_the_hash_of_the_original_string(self):
        assert hash(URLObject(self.url_string)) == hash(self.url_string)

    def test_calling_unicode_on_a_urlobject_returns_a_normal_string(self):
        url = URLObject(self.url_string)
        # Normally `type(x) is Y` is a bad idea, but it's exactly what we want.
        assert type(unicode(url)) is unicode
        assert unicode(url) == self.url_string


class URLObjectPropertyTest(unittest.TestCase):

    def setUp(self):
        self.url = URLObject(u"https://github.com/zacharyvoase/urlobject?spam=eggs#foo")

    def test_scheme_returns_scheme(self):
        assert self.url.scheme == u'https'

    def test_netloc_returns_netloc(self):
        assert self.url.netloc == u'github.com'

    def test_hostname_returns_hostname(self):
        assert self.url.hostname == u'github.com'
        url = URLObject("https://user:pass@github.com:443")
        assert url.hostname == u'github.com'

    def test_port_returns_port_or_None(self):
        assert self.url.port is None
        assert URLObject("https://github.com:412").port == 412
{'fraction_non_alphanumeric': 0.10132474042248478, 'fraction_numerical': 0.0053705692803437165, 'mean_word_length': 3.927689594356261, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5073620', 'n_tokens_mistral': 928, 'n_tokens_neox': 886, 'n_words': 160}