<commit_before># -*- coding: utf-8 -*-
"""
format-sql

Copyright (c) 2014, <NAME> (<EMAIL>)
All rights reserved.

"""
import os

from format_sql.file_handling import format_file, load_from_file, main


def get_test_file(filename):
    test_data = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
    filename = os.path.join(test_data, 'tests/data', filename)
    return filename


def test_format_empty_file():
    filename = get_test_file('empty.py')
    format_file(filename)
    assert load_from_file(filename) == ''<commit_msg>Add test for file iteration<commit_after># -*- coding: utf-8 -*-
"""
format-sql

Copyright (c) 2014, <NAME> (<EMAIL>)
All rights reserved.

"""
import os
import sys

from format_sql.file_handling import format_file, load_from_file, main

try:
    from unittest.mock import patch
except ImportError:
    from mock import patch


def get_test_file(filename):
    test_data = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
    filename = os.path.join(test_data, 'tests/data', filename)
    return filename


def test_format_empty_file():
    filename = get_test_file('empty.py')
    format_file(filename)
    assert load_from_file(filename) == ''


def test_main():
    sys.argv = ['NULL', 'tests']
    with patch('format_sql.file_handling.format_file') as mocked:
        main()
        assert mocked.call_count == 19
{'fraction_non_alphanumeric': 0.1291970802919708, 'fraction_numerical': 0.008759124087591242, 'mean_word_length': 4.252873563218391, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4525236', 'n_tokens_mistral': 469, 'n_tokens_neox': 448, 'n_words': 104}