<commit_before>"""Tests for streams.py."""

import unittest

from tulip import events
from tulip import streams
from tulip import tasks
from tulip import test_utils


class StreamReaderTests(unittest.TestCase):

    DATA = b'line1\nline2\nline3\n'

    def setUp(self):
        self.loop = events.new_event_loop()
        events.set_event_loop(None)

    def tearDown(self):
        self.loop.close()

    @unittest.mock.patch('tulip.streams.events')
    def test_ctor_global_loop(self, m_events):
        stream = streams.StreamReader()
        self.assertIs(stream.loop, m_events.get_event_loop.return_value)

    def test_open_connection(self):
        with test_utils.run_test_server(self.loop) as httpd:
            f = streams.open_connection(*httpd.address, loop=self.loop)<commit_msg>Restore running of tests/streams_test.py<commit_after>"""Tests for streams.py."""

import unittest
import unittest.mock

from tulip import events
from tulip import streams
from tulip import tasks
from tulip import test_utils


class StreamReaderTests(unittest.TestCase):

    DATA = b'line1\nline2\nline3\n'

    def setUp(self):
        self.loop = events.new_event_loop()
        events.set_event_loop(None)

    def tearDown(self):
        self.loop.close()

    @unittest.mock.patch('tulip.streams.events')
    def test_ctor_global_loop(self, m_events):
        stream = streams.StreamReader()
        self.assertIs(stream.loop, m_events.get_event_loop.return_value)

    def test_open_connection(self):
        with test_utils.run_test_server(self.loop) as httpd:
            f = streams.open_connection(*httpd.address, loop=self.loop)
{'fraction_non_alphanumeric': 0.09987745098039216, 'fraction_numerical': 0.003676470588235294, 'mean_word_length': 3.6524216524216526, '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': '4700986', 'n_tokens_mistral': 540, 'n_tokens_neox': 526, 'n_words': 104}