<commit_before>from __future__ import print_function

import unittest

from brennivin import compat, traceback2 as tb2


def get_funccode(func):
    if compat.PY3K:
        return func.__func__.__code__
    return func.im_func.func_code


class Traceback2Tests(unittest.TestCase):
    def test_print(self):
        """
        A high-level test to get some basic coverage.
        Not super useful but better than nothing!
        More specific tests can be added when changes need to be made.
        """
        out = compat.StringIO()
        try:
            raise SystemError()
        except SystemError:
            tb2.print_exc(file=out, show_locals=True)
        output = out.getvalue()
        lines = output.splitlines()
        try:
            self.assertEqual(lines[0], 'Traceback (most recent call last):')
            self.assertRegexpMatches(lines[1], '  File ".*test_traceback2.py", line \d\d, in test_print')
            self.assertEqual(lines[2], '    raise SystemError()')
            self.assertRegexpMatches(lines[3], '                 out = <.*\.String\w?O object at 0x([0-9]|[a-z])*>')
            self.assertEqual(lines[4], '                self = <tests.test_traceback2.Traceback2Tests testMethod=test_print>')
            self.assertEqual(lines[-1], 'SystemError')
        except AssertionError:  # pragma: no cover
            print(output)
            raise

    def clean(self, path):
        return path.replace('.pyc', '.py').replace('.pyo', '.py')<commit_msg>Was assuming StringO was ".StringO", pypy had just "String0". Must have changed in a newer version.<commit_after>from __future__ import print_function

import unittest

from brennivin import compat, traceback2 as tb2


def get_funccode(func):
    if compat.PY3K:
        return func.__func__.__code__
    return func.im_func.func_code


class Traceback2Tests(unittest.TestCase):
    def test_print(self):
        """
        A high-level test to get some basic coverage.
        Not super useful but better than nothing!
        More specific tests can be added when changes need to be made.
        """
        out = compat.StringIO()
        try:
            raise SystemError()
        except SystemError:
            tb2.print_exc(file=out, show_locals=True)
        output = out.getvalue()
        lines = output.splitlines()
        try:
            self.assertEqual(lines[0], 'Traceback (most recent call last):')
            self.assertRegexpMatches(lines[1], '  File ".*test_traceback2.py", line \d\d, in test_print')
            self.assertEqual(lines[2], '    raise SystemError()')
            self.assertRegexpMatches(lines[3], '                 out = <.*String\w?O object at 0x([0-9]|[a-z])*>')
            self.assertEqual(lines[4], '                self = <tests.test_traceback2.Traceback2Tests testMethod=test_print>')
            self.assertEqual(lines[-1], 'SystemError')
        except AssertionError:  # pragma: no cover
            print(output)
            raise

    def clean(self, path):
        return path.replace('.pyc', '.py').replace('.pyo', '.py')
{'fraction_non_alphanumeric': 0.11263020833333333, 'fraction_numerical': 0.011393229166666666, 'mean_word_length': 2.3658269441401973, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '324238', 'n_tokens_mistral': 901, 'n_tokens_neox': 889, 'n_words': 230}