<commit_before>import pdb
template = """

from distutils.core import setup, Extension

import sys
import pprint

from Cython.Distutils import build_ext

ext = Extension("test_files/out.cpp", language="c++",
        include_dirs = %(include_dirs)r,
        extra_compile_args = [],
        extra_link_args = [],
        )

setup(cmdclass = {'build_ext' : build_ext},
      name="test_main",
      version="0.0.1",
      ext_modules = [ext]
     )

"""

def test_from_command_line():
    import os
    old_dir = os.path.abspath(os.getcwd())
    os.chdir("test_files")
    args =  ["pxds/*.pxd", "--out", "out.pyx", "--addons=/addons",
                                                    "--converters=converters"]
    from autowrap.Main import _main
    try:
        _main(args)
    finally:
        os.chdir(old_dir)

def test_run():

    from autowrap.Main import run
    from autowrap.Utils import compile_and_import

    import glob
    import os
    print os.getcwd()

    pxds = glob.glob("test_files/pxds/*.pxd")
    assert pxds

    addons = glob.glob("test_files/addons/*.pyx")
    assert addons

    converters = ["test_files/converters"]

    extra_includes = ["test_files/includes"]
    includes = run(pxds, addons, converters, "test_files/out.pyx",
            extra_includes)

    mod = compile_and_import("out", ["test_files/out.cpp"], includes)

    ih = mod.IntHolder()<commit_msg>[TEST,FIX] can now be executed from any directory<commit_after>import pdb
template = """

from distutils.core import setup, Extension

import sys
import pprint

from Cython.Distutils import build_ext

ext = Extension("test_files/out.cpp", language="c++",
        include_dirs = %(include_dirs)r,
        extra_compile_args = [],
        extra_link_args = [],
        )

setup(cmdclass = {'build_ext' : build_ext},
      name="test_main",
      version="0.0.1",
      ext_modules = [ext]
     )

"""

def test_from_command_line():
    import os
    old_dir = os.path.abspath(os.getcwd())
    script_dir = os.path.dirname(os.path.abspath(__file__))
    os.chdir(os.path.join(script_dir, "test_files") )
    args =  ["pxds/*.pxd", "--out", "out.pyx", "--addons=/addons",
                                                    "--converters=converters"]
    from autowrap.Main import _main
    try:
        _main(args)
    finally:
        os.chdir(old_dir)

def test_run():

    from autowrap.Main import run
    from autowrap.Utils import compile_and_import

    import glob
    import os

    script_dir = os.path.dirname(os.path.abspath(__file__))

    pxds = glob.glob(script_dir + "/test_files/pxds/*.pxd")
    assert pxds

    addons = glob.glob(script_dir + "/test_files/addons/*.pyx")
    assert addons

    converters = [script_dir + "/test_files/converters"]

    extra_includes = [script_dir + "/test_files/includes"]
    includes = run(pxds, addons, converters, script_dir + "/test_files/out.pyx",
            extra_includes)

    mod = compile_and_import("out", [script_dir + "/test_files/out.cpp"], includes)

    ih = mod.IntHolder()
{'fraction_non_alphanumeric': 0.1326530612244898, 'fraction_numerical': 0.0019749835418038184, 'mean_word_length': 2.688106796116505, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7345968', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1018, 'n_words': 197}