<commit_before>import unittest
from random import randint, getrandbits
from pyModbusTCP.server import ModbusServer
from pyModbusTCP.client import ModbusClient
from pyModbusTCP.constants import SUPPORTED_FUNCTION_CODES, EXP_NONE, EXP_ILLEGAL_FUNCTION, MB_NO_ERR, MB_EXCEPT_ERR


# some const
MAX_READABLE_REGS = 125
MAX_WRITABLE_REGS = 123
MAX_READABLE_BITS = 2000
MAX_WRITABLE_BITS = 1968


class TestModbusClient(unittest.TestCase):
    def test_host(self):
        # default value
        self.assertEqual(ModbusClient().host, 'localhost')
        # should pass
        self.assertEqual(ModbusClient().host, 'LOCALHOST')
        self.assertEqual(ModbusClient().host, 'Localhost')
        self.assertEqual(ModbusClient().host, 'lOCALHOST')
        # should raise ValueError for bad value
        self.assertRaises(ValueError, ModbusClient, host='wrong@host')
        self.assertRaises(ValueError, ModbusClient, host='192.168.2.bad')
        self.assertRaises(ValueError, ModbusClient, host='::notip:1')
        # shouldn't raise ValueError for valid value
        try:
            [ModbusClient(host=h) for h in ['my.good.host', '127.0.0.1', '::1']]
        except ValueError:
            self.fail('ModbusClient.host property raised ValueError unexpectedly')

    def test_port(self):<commit_msg>fix tests for host validation<commit_after>import unittest
from random import randint, getrandbits
from pyModbusTCP.server import ModbusServer
from pyModbusTCP.client import ModbusClient
from pyModbusTCP.constants import SUPPORTED_FUNCTION_CODES, EXP_NONE, EXP_ILLEGAL_FUNCTION, MB_NO_ERR, MB_EXCEPT_ERR


# some const
MAX_READABLE_REGS = 125
MAX_WRITABLE_REGS = 123
MAX_READABLE_BITS = 2000
MAX_WRITABLE_BITS = 1968


class TestModbusClient(unittest.TestCase):
    def test_host(self):
        # default value
        self.assertEqual(ModbusClient().host, 'localhost')
        # should raise ValueError for bad value
        self.assertRaises(ValueError, ModbusClient, host='wrong@host')
        self.assertRaises(ValueError, ModbusClient, host='192.168.2.bad')
        self.assertRaises(ValueError, ModbusClient, host='::notip:1')
        # shouldn't raise ValueError for valid value
        try:
            [ModbusClient(host=h) for h in ['CamelCaseHost', 'my.good.host', '127.0.0.1', '::1']]
        except ValueError:
            self.fail('ModbusClient.host property raised ValueError unexpectedly')

    def test_port(self):
{'fraction_non_alphanumeric': 0.09506172839506173, 'fraction_numerical': 0.023868312757201648, 'mean_word_length': 4.054054054054054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '93863', 'n_tokens_mistral': 788, 'n_tokens_neox': 741, 'n_words': 170}