<commit_before>#!/usr/bin/env python3
import contextlib
import io
import textwrap
import unittest

import bytecode
from bytecode.tests import disassemble


class DumpCodeTests(unittest.TestCase):
    maxDiff = 80 * 100

    def check_dump_code(self, code, expected):
        with contextlib.redirect_stdout(io.StringIO()) as stderr:
            bytecode.dump_code(code)
            output = stderr.getvalue()

        self.assertEqual(output, expected)

    def test_bytecode(self):
        source = """
            def func(test):
                if test == 1:
                    return 1
                elif test == 2:
                    return 2
                return 3
        """
        code = disassemble(source, function=True)
        code = code.to_bytecode()

        expected = """
    LOAD_FAST 'test'
    LOAD_CONST 1
    COMPARE_OP 2
    POP_JUMP_IF_FALSE <label_instr6>
    LOAD_CONST 1
    RETURN_VALUE

label_instr6:
    LOAD_FAST 'test'
    LOAD_CONST 2
    COMPARE_OP 2
    POP_JUMP_IF_FALSE <label_instr13>
    LOAD_CONST 2
    RETURN_VALUE

label_instr13:
    LOAD_CONST 3
    RETURN_VALUE

        """[1:].rstrip(" ")
        print(expected)
        self.check_dump_code(code, expected)
<commit_msg>remove debug<commit_after>#!/usr/bin/env python3
import contextlib
import io
import textwrap
import unittest

import bytecode
from bytecode.tests import disassemble


class DumpCodeTests(unittest.TestCase):
    maxDiff = 80 * 100

    def check_dump_code(self, code, expected):
        with contextlib.redirect_stdout(io.StringIO()) as stderr:
            bytecode.dump_code(code)
            output = stderr.getvalue()

        self.assertEqual(output, expected)

    def test_bytecode(self):
        source = """
            def func(test):
                if test == 1:
                    return 1
                elif test == 2:
                    return 2
                return 3
        """
        code = disassemble(source, function=True)
        code = code.to_bytecode()

        expected = """
    LOAD_FAST 'test'
    LOAD_CONST 1
    COMPARE_OP 2
    POP_JUMP_IF_FALSE <label_instr6>
    LOAD_CONST 1
    RETURN_VALUE

label_instr6:
    LOAD_FAST 'test'
    LOAD_CONST 2
    COMPARE_OP 2
    POP_JUMP_IF_FALSE <label_instr13>
    LOAD_CONST 2
    RETURN_VALUE

label_instr13:
    LOAD_CONST 3
    RETURN_VALUE

        """[1:].rstrip(" ")
        self.check_dump_code(code, expected)

{'fraction_non_alphanumeric': 0.07917525773195876, 'fraction_numerical': 0.020618556701030927, 'mean_word_length': 2.0904458598726117, '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': '7219164', 'n_tokens_mistral': 824, 'n_tokens_neox': 737, 'n_words': 176}