<commit_before>"""Check all imports in the dashboard package

Find *.py under the dashboard package
    find all import lines in each file, and execute them
"""

import os
import unittest
from collections import defaultdict

from dotsite import imports


class TestDashboardImports(unittest.TestCase):
    def setUp(self):
        source = __file__.replace('.pyc', '.py')  # just in case
        self.visitor = imports.extract_imports(source)

    def test_import_count(self):
        """Check that we can find imports in a file

        Simple check - just make sure we can count imports here
        Adding some unusual imports in this test
            to make sure getting more than top-level imports
            and can handle the edge-cases
        """
        import os, sys
        from os import (path,
                        kill)
        self.assertEqual(len(self.visitor.imports), 7)
        self.assertEqual(len(self.visitor.froms), 3)
        self.assertEqual(len(self.visitor.used), 2)
        p = os.path

    def test_redundant_imports(self):
        self.assertEqual(
            set(self.visitor.unused().keys()),
            {'defaultdict', 'sys', 'kill', 'path', 'os'})

    def test_mutiples(self):
        """Check that mutiple imports of 'os' are found

        They are on lines 7 and 27
        """
        self.assertEquals(self.visitor.mutiples().keys(), ['os'])<commit_msg>Remove debugging code<commit_after>"""Check all imports in the dashboard package

Find *.py under the dashboard package
    find all import lines in each file, and execute them
"""

import os
import unittest
from collections import defaultdict

from dotsite import imports


class TestDashboardImports(unittest.TestCase):
    def setUp(self):
        source = __file__.replace('.pyc', '.py')  # just in case
        self.visitor = imports.extract_imports(source)

    def test_import_count(self):
        """Check that we can find imports in a file

        Simple check - just make sure we can count imports here
        Adding some unusual imports in this test
            to make sure getting more than top-level imports
            and can handle the edge-cases
        """
        import os, sys
        from os import (path,
                        kill)
        self.assertEqual(len(self.visitor.imports), 7)
        self.assertEqual(len(self.visitor.froms), 3)
        self.assertEqual(len(self.visitor.used), 2)

    def test_redundant_imports(self):
        self.assertEqual(
            set(self.visitor.unused().keys()),
            {'defaultdict', 'sys', 'kill', 'path', 'os'})

    def test_mutiples(self):
        """Check that mutiple imports of 'os' are found

        They are on lines 7 and 27
        """
        self.assertEquals(self.visitor.mutiples().keys(), ['os'])
{'fraction_non_alphanumeric': 0.09670487106017192, 'fraction_numerical': 0.004297994269340974, 'mean_word_length': 2.4782067247820674, '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': '3368667', 'n_tokens_mistral': 783, 'n_tokens_neox': 745, 'n_words': 263}