<commit_before>"""
@brief      test tree node (time=5s)
"""


import sys
import os
import unittest
import re
import shutil
import warnings

try:
    import src
except ImportError:
    path = os.path.normpath(
        os.path.abspath(
            os.path.join(
                os.path.split(__file__)[0],
                "..",
                "..")))
    if path not in sys.path:
        sys.path.append(path)
    import src

from src.pyquickhelper import fLOG, get_temp_folder, __blog__
from src.pyquickhelper.pycode.code_helper import remove_extra_spaces_and_pep8, remove_extra_spaces_folder
from src.pyquickhelper.pycode.clean_helper import clean_exts


class TestClean(unittest.TestCase):

    def test_pep8(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        this = os.path.abspath(__file__.replace(".pyc", ".py"))
        diff = remove_extra_spaces_and_pep8(this)
        assert diff < 10

    def test_extra_space(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        this = os.path.abspath(os.path.dirname(__file__))
        diff = remove_extra_spaces_folder(this)
        assert isinstance(diff, list)

    def test_clean_exts(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if "Anaconda" in sys.executable:
            # we disable it for Anaconda
            return
        this = os.path.abspath(os.path.dirname(__file__))
        diff = clean_exts(this)
        assert isinstance(diff, list)


if __name__ == "__main__":
    unittest.main()<commit_msg>update unit tests for Anaconda<commit_after>"""
@brief      test tree node (time=5s)
"""


import sys
import os
import unittest
import re
import shutil
import warnings

try:
    import src
except ImportError:
    path = os.path.normpath(
        os.path.abspath(
            os.path.join(
                os.path.split(__file__)[0],
                "..",
                "..")))
    if path not in sys.path:
        sys.path.append(path)
    import src

from src.pyquickhelper import fLOG, get_temp_folder, __blog__
from src.pyquickhelper.pycode.code_helper import remove_extra_spaces_and_pep8, remove_extra_spaces_folder
from src.pyquickhelper.pycode.clean_helper import clean_exts


class TestClean(unittest.TestCase):

    def test_pep8(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        this = os.path.abspath(__file__.replace(".pyc", ".py"))
        diff = remove_extra_spaces_and_pep8(this)
        assert diff < 10

    def test_extra_space(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        this = os.path.abspath(os.path.dirname(__file__))
        diff = remove_extra_spaces_folder(this)
        assert isinstance(diff, list)

    def test_clean_exts(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        this = os.path.abspath(os.path.dirname(__file__))
        try:
            diff = clean_exts(this)
        except PermissionError as e:
            if "Anaconda" in sys.executable:
                # we disable it for Anaconda
                return
            raise Exception("unable to clean " + this +
                            "\nexe: " + sys.executable) from e
        assert isinstance(diff, list)


if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.0948703805846663, 'fraction_numerical': 0.003861003861003861, 'mean_word_length': 2.137543252595156, 'pattern_counts': {'":': 2, '<': 5, '<?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': '107763', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1097, 'n_words': 237}