<commit_before>from __future__ import print_function
import os
import pytest
from mock import MagicMock
import sys
from dkconfig import main, dkconfig


@pytest.fixture
def sysexit(monkeypatch):
    mock_exit = MagicMock()
    monkeypatch.setattr(sys, 'exit', mock_exit)
    return mock_exit


def test_debug(tmpdir, sysexit, capsys):
    file = tmpdir.join("foo.ini")
    main("%s get header key -d" % file)
    sysexit.assert_called_with(1)
    out, err = capsys.readouterr()
    err = err.replace('\\', '')
    file = str(file).replace('\\','')
    compare = """ARGS: Namespace(command='get', debug=True, filename=['%s']) ['header', 'key']\n""" % file
    assert err == compare<commit_msg>Fix py3.9 issue in test.<commit_after>from __future__ import print_function
import os
import pytest
from mock import MagicMock
import sys
from dkconfig import main, dkconfig


@pytest.fixture
def sysexit(monkeypatch):
    mock_exit = MagicMock()
    monkeypatch.setattr(sys, 'exit', mock_exit)
    return mock_exit


def test_debug(tmpdir, sysexit, capsys):
    file = tmpdir.join("foo.ini")
    main("%s get header key -d" % file)
    sysexit.assert_called_with(1)
    out, err = capsys.readouterr()
    err = err.replace('\\', '').strip()
    file = str(file).replace('\\','')
    # compare = """ARGS: Namespace(command='get', debug=True, filename=['%s']) ['header', 'key']""" % file
    # py39 = """ARGS: Namespace(filename=['%s'], command='get', debug=True) ['header', 'key']""" % file
    assert err.endswith(" ['header', 'key']")
    err = err[:-len(" ['header', 'key']")]
    assert err.startswith("ARGS: ")
    err = err[len("ARGS: "):]
    errdict = eval(err, {"Namespace": dict})  # should be valid Python by now, convert Namespace to dict
    assert errdict['command'] == 'get'
    assert errdict['debug'] is True
    assert errdict['filename'] == [file]
{'fraction_non_alphanumeric': 0.16908992999461497, 'fraction_numerical': 0.0032310177705977385, 'mean_word_length': 4.204481792717087, 'pattern_counts': {'":': 1, '<': 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': '4296473', 'n_tokens_mistral': 627, 'n_tokens_neox': 620, 'n_words': 165}