<commit_before>from test.context import pf

from unittest.mock import MagicMock, patch

import types
import unittest


class TypedNode(pf.core.Node):
    _input_types = [str]
    _output_type = int

    def apply(self, in_str):
        yield len(in_str)


class TestNodeInitialization(unittest.TestCase):

    def test_node_sets_id_properly(self):
        node_id = 'hello'

        n = pf.core.Node(id=node_id)
        self.assertEqual(n.id, node_id)

    def test_node_defaults_id_properly(self):
        expected_id = 'node'

        n = pf.core.Node()
        self.assertEqual(n.id, expected_id)

    def test_node_enables_typecheck_when_types_are_defined(self):
        with patch('pictureflow.core.Node._validate_parent_types', MagicMock()):
            n = TypedNode()
            self.assertTrue(n._typecheck_enabled)

    def test_node_disables_typecheck_when_no_types_are_defined(self):
        n = pf.core.Node()

        self.assertFalse(n._typecheck_enabled)

    def test_node_sets_parents(self):
        parents = ('a', 'b', 'c')

        n = pf.core.Node('node', *parents)
<commit_msg>Fix test<commit_after>from test.context import pf

from unittest.mock import MagicMock, patch

import types
import unittest


class TypedNode(pf.core.Node):
    _input_types = [str]
    _output_type = int

    def apply(self, in_str):
        yield len(in_str)


class TestNodeInitialization(unittest.TestCase):

    def test_node_sets_id_properly(self):
        node_id = 'hello'

        n = pf.core.Node(id=node_id)
        self.assertEqual(n.id, node_id)

    def test_node_defaults_id_properly(self):
        expected_id = 'node'

        n = pf.core.Node()
        self.assertEqual(n.id, expected_id)

    def test_node_enables_typecheck_when_types_are_defined(self):
        with patch('pictureflow.core.Node._validate_parent_types', MagicMock()):
            n = TypedNode()
            self.assertTrue(n._typecheck_enabled)

    def test_node_disables_typecheck_when_no_types_are_defined(self):
        n = pf.core.Node()

        self.assertFalse(n._typecheck_enabled)

    def test_node_sets_parents(self):
        parents = ['a', 'b', 'c']

        n = pf.core.Node('node', *parents)

{'fraction_non_alphanumeric': 0.10377787892580792, 'fraction_numerical': 0.0, 'mean_word_length': 3.1161048689138577, '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': '746713', 'n_tokens_mistral': 758, 'n_tokens_neox': 731, 'n_words': 129}