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) == ''

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

Add test for file iteration
Add test for file iteration

  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
+ 
Add test for file iteration
## Code Before:
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) == ''

## Instruction:
Add test for file iteration
## Code After:
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
