<commit_before>from os import listdir
import re

from stacktach import migrations

from tests.unit import StacktachBaseTestCase


class MigrationsTestCase(StacktachBaseTestCase):
    def test_no_duplicate_numbers(self):
        migrs = {}

        migrations_file = migrations.__file__
        migrations_dir = migrations_file[:-len('__init__.py')-1]

        migr_match = re.compile('[0-9]{4}.*.py')
        files = [f for f in listdir(migrations_dir)
                 if re.match(migr_match, f)]

        for f in files:
            migr_number = f[0:4]
            migr_list = migrs.get(migr_number, [])
            migr_list.append(f)
            migrs[migr_number] = migr_list

        dups = []
        for num in migrs:
            if len(migrs[num]) > 1:
                dups.append(num)

        msg = "Duplicate migrations found for number(s) %s" % ' '.join(dups)
        self.assertEqual(len(dups), 0, msg)<commit_msg>Accounting for *.pyc in migrations check<commit_after>from os import listdir
import re

from stacktach import migrations

from tests.unit import StacktachBaseTestCase


class MigrationsTestCase(StacktachBaseTestCase):
    def test_no_duplicate_numbers(self):
        migrs = {}

        migrations_file = migrations.__file__
        migrations_dir = migrations_file[:-len('__init__.py')-1]

        migr_match = re.compile('^[0-9]{4}.*.py$')
        files = [f for f in listdir(migrations_dir)
                 if re.match(migr_match, f)]

        for f in files:
            migr_number = f[0:4]
            migr_list = migrs.get(migr_number, [])
            migr_list.append(f)
            migrs[migr_number] = migr_list

        dups = []
        for num in migrs:
            if len(migrs[num]) > 1:
                dups.append(num)

        msg = "Duplicate migrations found for number(s) %s" % ' '.join(dups)
        self.assertEqual(len(dups), 0, msg)
{'fraction_non_alphanumeric': 0.10704822469528352, 'fraction_numerical': 0.008479067302596715, 'mean_word_length': 2.3181019332161688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4993894', 'n_tokens_mistral': 604, 'n_tokens_neox': 619, 'n_words': 134}