<commit_before>import pytest
from misuzu import Misuzu
from misuzu.config import *
from misuzu.utils import *


def test_get_env(tmpdir):
    app = Misuzu("test")
    t = tmpdir.mkdir("sub").join("config.toml")
    t.write("home = 'ENV::HOME::STR'")
    app.config.load(t)
    p = os.environ.get("HOME")
    assert app.config['home'] == p


def test_nested_dict(tmpdir):
    app = Misuzu("test")
    t = tmpdir.mkdir("sub").join("config.toml")
    t.write("[a]\naa = 1\n[a.b]\nbb = 2")
    app.config.load(t)
    p = {
        'a': {'aa': 1, 'b': {'bb': 2}}
    }
    assert app.config == p


def test_no_env(tmpdir):
    app = Misuzu("test")
    t = tmpdir.mkdir("sub").join("config.toml")
    t.write("home = 'ENV::HOMES::STR::/'")
    app.config.load(t)
    assert app.config['home'] == "/"


def test_no_type(tmpdir):
    with pytest.raises(ConfigException):
        app = Misuzu("test")
        t = tmpdir.mkdir("sub").join("config.toml")
        t.write("home = 'ENV::HOME::SSS::/'")
        app.config.load(t)


def test_no_capitalized(tmpdir):
    with pytest.raises(ConfigException):
        app = Misuzu("test")
        t = tmpdir.mkdir("sub").join("config.toml")
        t.write("home = 'ENV::Home::STR::/'")
        app.config.load(t)<commit_msg>test: add test for use func<commit_after>import pytest
from misuzu import Misuzu
from misuzu.config import *
from misuzu.utils import *


def test_get_env(tmpdir):
    app = Misuzu("test")
    t = tmpdir.mkdir("sub").join("config.toml")
    t.write("home = 'ENV::HOME::STR'")
    app.config.load(t)
    p = os.environ.get("HOME")
    assert app.config['home'] == p


def test_nested_dict(tmpdir):
    app = Misuzu("test")
    t = tmpdir.mkdir("sub").join("config.toml")
    t.write("[a]\naa = 1\n[a.b]\nbb = 2")
    app.config.load(t)
    p = {
        'a': {'aa': 1, 'b': {'bb': 2}}
    }
    assert app.config == p


def test_no_env(tmpdir):
    app = Misuzu("test")
    t = tmpdir.mkdir("sub").join("config.toml")
    t.write("home = 'ENV::HOMES::STR::/'")
    app.config.load(t)
    assert app.config['home'] == "/"


def test_no_type(tmpdir):
    with pytest.raises(ConfigException):
        app = Misuzu("test")
        t = tmpdir.mkdir("sub").join("config.toml")
        t.write("home = 'ENV::HOME::SSS::/'")
        app.config.load(t)


def test_no_capitalized(tmpdir):
    with pytest.raises(ConfigException):
        app = Misuzu("test")
        t = tmpdir.mkdir("sub").join("config.toml")
        t.write("home = 'ENV::Home::STR::/'")
        app.config.load(t)


def test_exist_type_func():
    with pytest.raises(ConfigException):
        app = Misuzu("test")

        def into():
            pass
        app.config.use("STR", into)


def test_add_type(tmpdir):
    def double(value):
        return False, value

    app = Misuzu("test")
    t = tmpdir.mkdir("sub").join("config.toml")
    t.write("home = 'ENV::HOME::DOUBLE'")
    app.config.use("DOUBLE", double)
    app.config.load(t)
    p = (False, os.environ.get("HOME"))
    assert app.config == {'home': p}
{'fraction_non_alphanumeric': 0.19624629568653276, 'fraction_numerical': 0.0026341784655910436, 'mean_word_length': 2.935233160621762, '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': '618950', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1142, 'n_words': 196}