<commit_before>#import unittest
import mt
import queue
import _thread
import time
class DummySocket:

    def __init__(self, ID):
        self.id = ID
        self.lastMsg = ""

    def send(self, msg):
        print(self.id+":",msg)
        self.lastMsg = msg

    def close(self):
        print(self.id+": CLOSE CALLED")
        self.lastMsg = "CLOSED"

    def getpeername(self):
        return self.id, 0

##class TestMt(unittest.TestCase):
##
##    def test_listener_thread(self):
##        data = queue.Queue()
##        s1 = DummySocket("0")
##        s2 = DummySocket("1")
##
##        listenerObj = mt.ListenerThread(data)
##
##        def sender():
##            time.sleep(1)
##            data.put("Hello, World")
##            time.sleep(0.1)
##            listenerObj.add(s2)
##            time.sleep(1)
##            data.put("Hello, World 2")
##            time.sleep(1)
##            listenerObj.removeIP("0")
##            data.put("Hello, World 3")
##
##            data.put("!!INTERNAL=SHUTDOWN!!")
##
##        listenerObj.add(s1)
##        _thread.start_new_thread(sender, ())
##        listenerObj.main()
##
##        self.assertEqual(s1.lastMsg, "CLOSED")
##        self.assertEqual(s2.lastMsg, b"Hello, World 3\r\n")


def test_listener_thread(self):
        data = queue.Queue()
        s1 = DummySocket("0")
        s2 = DummySocket("1")

        listenerObj = mt.ListenerThread(data)

        def sender():
            time.sleep(1)
            data.put("Hello, World")
            time.sleep(0.1)
            listenerObj.add(s2)
            time.sleep(1)
            data.put("Hello, World 2")
            time.sleep(1)<commit_msg>UNITTEST<commit_after>#import unittest
import mt
import queue
import _thread
import time
class DummySocket:

    def __init__(self, ID):
        self.id = ID
        self.lastMsg = ""

    def send(self, msg):
        print(self.id+":",msg)
        self.lastMsg = msg

    def close(self):
        print(self.id+": CLOSE CALLED")
        self.lastMsg = "CLOSED"

    def getpeername(self):
        return self.id, 0

##class TestMt(unittest.TestCase):
##
##    def test_listener_thread(self):
##        data = queue.Queue()
##        s1 = DummySocket("0")
##        s2 = DummySocket("1")
##
##        listenerObj = mt.ListenerThread(data)
##
##        def sender():
##            time.sleep(1)
##            data.put("Hello, World")
##            time.sleep(0.1)
##            listenerObj.add(s2)
##            time.sleep(1)
##            data.put("Hello, World 2")
##            time.sleep(1)
##            listenerObj.removeIP("0")
##            data.put("Hello, World 3")
##
##            data.put("!!INTERNAL=SHUTDOWN!!")
##
##        listenerObj.add(s1)
##        _thread.start_new_thread(sender, ())
##        listenerObj.main()
##
##        self.assertEqual(s1.lastMsg, "CLOSED")
##        self.assertEqual(s2.lastMsg, b"Hello, World 3\r\n")


def test_listener_thread():
        data = queue.Queue()
        s1 = DummySocket("0")
        s2 = DummySocket("1")

        listenerObj = mt.ListenerThread(data)

        def sender():
            time.sleep(1)
            data.put("Hello, World")
            time.sleep(0.1)
            listenerObj.add(s2)
            time.sleep(1)
            data.put("Hello, World 2")
            time.sleep(1)
{'fraction_non_alphanumeric': 0.15826034430685593, 'fraction_numerical': 0.017517366354575657, 'mean_word_length': 1.9335695305580158, 'pattern_counts': {'":': 4, '<': 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': '2092256', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1072, 'n_words': 191}