<commit_before>import unittest
import owebunit

class AbsolutizeUrlTestCase(unittest.TestCase):
    def test_noop(self):
        config = owebunit.Config()
        config.host = config.port = config.protocol = None
        url = 'http://absolute/url'
        self._perform(config, url, url)
    
    def test_with_host(self):
        config = owebunit.Config()
        config.host = 'host'
        config.port = config.protocol = None
        url = '/path'
        expected = 'http://host/path'
        self._perform(config, url, expected)
    
    def test_with_host_and_port(self):
        config = owebunit.Config()
        config.host = 'host'
        config.port = 8080
        config.protocol = None
        url = '/path'
        expected = 'http://host:8080/path'
        self._perform(config, url, expected)
    
    def test_with_host_and_port_as_url(self):
        config = owebunit.Config()
        config.host = 'http://host:8080'
        config.port = config.protocol = None
        url = '/path'
        expected = 'http://host:8080/path'
        self._perform(config, url, expected)
    
    def _perform(self, config, url, expected):
        session = owebunit.Session(config, None)
        absolutized = session._absolutize_url(url)
        self.assertEqual(expected, absolutized)

if __name__ == '__main__':
    import unittest
    unittest.main()<commit_msg>Check that port only produces an error<commit_after>import unittest
import owebunit

class AbsolutizeUrlTestCase(unittest.TestCase):
    def test_noop(self):
        config = owebunit.Config()
        config.host = config.port = config.protocol = None
        url = 'http://absolute/url'
        self._perform(config, url, url)
    
    def test_with_host(self):
        config = owebunit.Config()
        config.host = 'host'
        config.port = config.protocol = None
        url = '/path'
        expected = 'http://host/path'
        self._perform(config, url, expected)
    
    def test_with_host_and_port(self):
        config = owebunit.Config()
        config.host = 'host'
        config.port = 8080
        config.protocol = None
        url = '/path'
        expected = 'http://host:8080/path'
        self._perform(config, url, expected)
    
    def test_with_host_and_port_as_url(self):
        config = owebunit.Config()
        config.host = 'http://host:8080'
        config.port = config.protocol = None
        url = '/path'
        expected = 'http://host:8080/path'
        self._perform(config, url, expected)
    
    def test_with_port_only(self):
        config = owebunit.Config()
        config.host = None
        config.port = 8080
        config.protocol = None
        url = '/path'
        expected = 'http://host:8080/path'
        self.assertRaises(ValueError, self._perform, config, url, expected)
    
    def _perform(self, config, url, expected):
        session = owebunit.Session(config, None)
        absolutized = session._absolutize_url(url)
        self.assertEqual(expected, absolutized)

if __name__ == '__main__':
    import unittest
    unittest.main()
{'fraction_non_alphanumeric': 0.11331168831168831, 'fraction_numerical': 0.012987012987012988, 'mean_word_length': 2.316469321851453, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1869278', 'n_tokens_mistral': 947, 'n_tokens_neox': 924, 'n_words': 196}