<commit_before>from pep257 import (StringIO, TokenStream, Parser,
                    Module, Class, Method, Function, NestedFunction)


_ = type('', (), dict(__repr__=lambda *a: '_', __eq__=lambda *a: True))()


parse = Parser()
source = '''
"""Module."""
__all__ = ('a', 'b'
           'c',)
def function():
    "Function."
    def nested_1():
        """Nested."""
    if True:
        def nested_2():
            pass
class class_(object):
    """Class."""
    def method_1(self):
        """Method."""
    def method_2(self):
        def nested_3(self):
            """Nested."""
'''


def test_parser():
    all = ('a', 'bc')
    module = parse(StringIO(source), 'file.py')
    assert len(list(module)) == 8
    assert Module('file.py', _, 1, len(source.split('\n')),
                  '"""Module."""', _, _, all) == module

    print map(str, module.children[0].children)
    function, class_ = module.children
    assert Function('function', _, _, _, '"Function."', _, module) == function
    assert Class('class_', _, _, _, '"""Class."""', _, module) == class_
<commit_msg>Remove print call that was used for debugging<commit_after>from pep257 import (StringIO, TokenStream, Parser,
                    Module, Class, Method, Function, NestedFunction)


_ = type('', (), dict(__repr__=lambda *a: '_', __eq__=lambda *a: True))()


parse = Parser()
source = '''
"""Module."""
__all__ = ('a', 'b'
           'c',)
def function():
    "Function."
    def nested_1():
        """Nested."""
    if True:
        def nested_2():
            pass
class class_(object):
    """Class."""
    def method_1(self):
        """Method."""
    def method_2(self):
        def nested_3(self):
            """Nested."""
'''


def test_parser():
    all = ('a', 'bc')
    module = parse(StringIO(source), 'file.py')
    assert len(list(module)) == 8
    assert Module('file.py', _, 1, len(source.split('\n')),
                  '"""Module."""', _, _, all) == module

    function, class_ = module.children
    assert Function('function', _, _, _, '"Function."', _, module) == function
    assert Class('class_', _, _, _, '"""Class."""', _, module) == class_

{'fraction_non_alphanumeric': 0.2015828677839851, 'fraction_numerical': 0.009776536312849162, 'mean_word_length': 2.686106346483705, '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': '3700095', 'n_tokens_mistral': 682, 'n_tokens_neox': 658, 'n_words': 166}