<commit_before>import unittest

from nose.tools import assert_raises

from urlobject.netloc import Netloc


class NetlocTest(unittest.TestCase):

    def test_preserves_equality_of_the_original_string(self):
        netloc = u'zack:<EMAIL>:443'
        assert Netloc(netloc) == netloc

    def test_preserves_hash_of_the_original_string(self):
        netloc = u'zack:<EMAIL>:443'
        assert hash(Netloc(netloc)) == hash(netloc)

    def test_username(self):
        assert Netloc(u'github.com').username is None
        assert Netloc(u'<EMAIL>').username == u'zack'
        assert Netloc(u'zack:<EMAIL>').username == u'zack'

    def test_with_username_adds_username(self):
        assert Netloc(u'github.com').with_username(u'zack') == u'<EMAIL>'

    def test_with_username_replaces_username(self):
        assert (Netloc(u'<EMAIL>').with_username(u'alice') ==
                u'<EMAIL>')
        assert (Netloc(u'zack:<EMAIL>').with_username(u'alice') ==
                u'alice:<EMAIL>')

    def test_without_username_removes_username(self):
        assert Netloc(u'github.com').without_username() == u'github.com'
        assert Netloc(u'<EMAIL>').without_username() == u'github.com'
        # Removing the username will also remove the password.
        assert Netloc(u'zack:<EMAIL>').without_username() == u'github.com:443'

    def test_password(self):
        assert Netloc(u'github.com').password is None
        assert Netloc(u'<EMAIL>').password is None
        assert Netloc(u'zack:<EMAIL>').password == u'<PASSWORD>'

    def test_with_password_adds_password(self):
        assert (Netloc('<EMAIL>').with_password('<PASSWORD>') ==
                u'zack:<EMAIL>')

    def test_with_password_replaces_password(self):
        assert (Netloc(u'zack:<EMAIL>:443').with_password('<PASSWORD>') ==
                u'zack:<EMAIL>:443')

    def test_with_password_on_a_netloc_with_no_username_raises_ValueError(self):
        assert_raises(ValueError,
                      lambda: Netloc('github.com').with_password('<PASSWORD>'))

    def test_hostname(self):
        assert Netloc(u'zack:<EMAIL>:443').hostname == u'github.com'

    def test_with_hostname_replaces_hostname(self):
        assert (Netloc(u'zack:<EMAIL>:443').with_hostname('example.com') ==
                u'zack:<EMAIL>:443')

    def test_port(self):
        assert Netloc(u'github.com:443').port == 443
        assert Netloc(u'github.com').port is None

    def test_with_port_adds_port(self):
        assert Netloc(u'github.com').with_port(443) == u'github.com:443'

    def test_with_port_replaces_port(self):
        assert Netloc(u'github.com:443').with_port(80) == u'github.com:80'

    def test_without_port_removes_port(self):
        assert Netloc(u'github.com:443').without_port() == u'github.com'
<commit_msg>Fixed another typo in the netloc test.<commit_after>import unittest

from nose.tools import assert_raises

from urlobject.netloc import Netloc


class NetlocTest(unittest.TestCase):

    def test_preserves_equality_of_the_original_string(self):
        netloc = u'zack:<EMAIL>:443'
        assert Netloc(netloc) == netloc

    def test_preserves_hash_of_the_original_string(self):
        netloc = u'zack:<EMAIL>:443'
        assert hash(Netloc(netloc)) == hash(netloc)

    def test_username(self):
        assert Netloc(u'github.com').username is None
        assert Netloc(u'<EMAIL>').username == u'zack'
        assert Netloc(u'zack:<EMAIL>').username == u'zack'

    def test_with_username_adds_username(self):
        assert Netloc(u'github.com').with_username(u'zack') == u'<EMAIL>'

    def test_with_username_replaces_username(self):
        assert (Netloc(u'<EMAIL>').with_username(u'alice') ==
                u'<EMAIL>')
        assert (Netloc(u'zack:<EMAIL>').with_username(u'alice') ==
                u'alice:<EMAIL>')

    def test_without_username_removes_username(self):
        assert Netloc(u'github.com').without_username() == u'github.com'
        assert Netloc(u'<EMAIL>').without_username() == u'github.com'
        # Removing the username will also remove the password.
        assert Netloc(u'zack:<EMAIL>:443').without_username() == u'github.com:443'

    def test_password(self):
        assert Netloc(u'github.com').password is None
        assert Netloc(u'<EMAIL>').password is None
        assert Netloc(u'zack:<EMAIL>').password == u'<PASSWORD>'

    def test_with_password_adds_password(self):
        assert (Netloc('z<EMAIL>').with_password('<PASSWORD>') ==
                u'zack:<EMAIL>')

    def test_with_password_replaces_password(self):
        assert (Netloc(u'zack:<EMAIL>:443').with_password('<PASSWORD>') ==
                u'zack:<EMAIL>:443')

    def test_with_password_on_a_netloc_with_no_username_raises_ValueError(self):
        assert_raises(ValueError,
                      lambda: Netloc('github.com').with_password('<PASSWORD>'))

    def test_hostname(self):
        assert Netloc(u'zack:<EMAIL>:443').hostname == u'github.com'

    def test_with_hostname_replaces_hostname(self):
        assert (Netloc(u'zack:<EMAIL>:443').with_hostname('example.com') ==
                u'zack:<EMAIL>:443')

    def test_port(self):
        assert Netloc(u'github.com:443').port == 443
        assert Netloc(u'github.com').port is None

    def test_with_port_adds_port(self):
        assert Netloc(u'github.com').with_port(443) == u'github.com:443'

    def test_with_port_replaces_port(self):
        assert Netloc(u'github.com:443').with_port(80) == u'github.com:80'

    def test_without_port_removes_port(self):
        assert Netloc(u'github.com:443').without_port() == u'github.com'

{'fraction_non_alphanumeric': 0.14184397163120568, 'fraction_numerical': 0.016843971631205674, 'mean_word_length': 3.669701986754967, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '1028160', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1899, 'n_words': 270}