<commit_before>import re
from os import listdir
from os.path import join, dirname

import test_utils

import manage


class MigrationTests(test_utils.TestCase):
    """Sanity checks for the SQL migration scripts."""

    @staticmethod
    def _migrations_path():
        """Return the absolute path to the migration script folder."""
        return manage.path('migrations')

    def test_unique(self):
        """Assert that the numeric prefixes of the DB migrations are unique."""
        leading_digits = re.compile(r'^\d+')
        seen_numbers = set()
        path = self._migrations_path()
        for filename in listdir(path):
            match = leading_digits.match(filename)
            if match:
                number = match.group()
                if number in seen_numbers:
                    self.fail('There is more than one migration #%s in %s.' %
                              (number, path))
                seen_numbers.add(number)<commit_msg>bug660779, prevent picking up backup files, r=Pike<commit_after>import re
from os import listdir
from os.path import join, dirname, splitext

import test_utils

import manage


class MigrationTests(test_utils.TestCase):
    """Sanity checks for the SQL migration scripts."""

    @staticmethod
    def _migrations_path():
        """Return the absolute path to the migration script folder."""
        return manage.path('migrations')

    def test_unique(self):
        """Assert that the numeric prefixes of the DB migrations are unique."""
        leading_digits = re.compile(r'^\d+')
        seen_numbers = set()
        path = self._migrations_path()
        for filename in listdir(path):
            __, ext = splitext(filename)
            # prevent matching backup files (e.g. 001_foo.sql~)
            if ext not in [".sql", ".py"]: # same as nashvegas
                continue
            match = leading_digits.match(filename)
            if match:
                number = match.group()
                if number in seen_numbers:
                    self.fail('There is more than one migration #%s in %s.' %
                              (number, path))
                seen_numbers.add(number)
{'fraction_non_alphanumeric': 0.09208103130755065, 'fraction_numerical': 0.004143646408839779, 'mean_word_length': 2.1447178002894356, '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': '508629', 'n_tokens_mistral': 587, 'n_tokens_neox': 560, 'n_words': 190}