<commit_before>import os
import subprocess

from julia.core import juliainfo, _enviorn


def check_core_juliainfo(jlinfo):
    assert os.path.exists(jlinfo.JULIA_HOME)
    assert os.path.exists(jlinfo.libjulia_path)
    assert os.path.exists(jlinfo.image_file)


def test_juliainfo_normal():
    jlinfo = juliainfo(os.getenv("JULIA_EXE", "julia"))
    check_core_juliainfo(jlinfo)
    assert os.path.exists(jlinfo.pyprogramname)
    # Note: jlinfo.libpython is probably not a full path so we are not
    # testing it here.


def test_juliainfo_without_pycall(tmpdir):
    """
    `juliainfo` should not fail even when PyCall.jl is not installed.
    """

    runtime = os.getenv("JULIA_EXE", "julia")

    JULIA_DEPOT_PATH = subprocess.check_output(
        [runtime, "-e", """
        paths = [ARGS[1], DEPOT_PATH[2:end]...]
        print(join(paths, Sys.iswindows() ? ';' : ':'))
        """, str(tmpdir)],
        env=_enviorn,
        universal_newlines=True)

    jlinfo = juliainfo(
        runtime,
        env=dict(_enviorn, JULIA_DEPOT_PATH=JULIA_DEPOT_PATH))

    check_core_juliainfo(jlinfo)
    assert jlinfo.pyprogramname is None
    assert jlinfo.libpython is None<commit_msg>Fix test_juliainfo_without_pycall for Julia 0.6<commit_after>import os
import subprocess

from julia.core import juliainfo, _enviorn


def check_core_juliainfo(jlinfo):
    assert os.path.exists(jlinfo.JULIA_HOME)
    assert os.path.exists(jlinfo.libjulia_path)
    assert os.path.exists(jlinfo.image_file)


def test_juliainfo_normal():
    jlinfo = juliainfo(os.getenv("JULIA_EXE", "julia"))
    check_core_juliainfo(jlinfo)
    assert os.path.exists(jlinfo.pyprogramname)
    # Note: jlinfo.libpython is probably not a full path so we are not
    # testing it here.


def test_juliainfo_without_pycall(tmpdir):
    """
    `juliainfo` should not fail even when PyCall.jl is not installed.
    """

    runtime = os.getenv("JULIA_EXE", "julia")

    env_var = subprocess.check_output(
        [runtime, "--startup-file=no", "-e", """
        if VERSION < v"0.7-"
            println("JULIA_PKGDIR")
            print(ARGS[1])
        else
            paths = [ARGS[1], DEPOT_PATH[2:end]...]
            println("JULIA_DEPOT_PATH")
            print(join(paths, Sys.iswindows() ? ';' : ':'))
        end
        """, str(tmpdir)],
        env=_enviorn,
        universal_newlines=True)
    name, val = env_var.split("\n", 1)

    jlinfo = juliainfo(
        runtime,
        env=dict(_enviorn, **{name: val}))

    check_core_juliainfo(jlinfo)
    assert jlinfo.pyprogramname is None
    assert jlinfo.libpython is None
{'fraction_non_alphanumeric': 0.11877394636015326, 'fraction_numerical': 0.0038314176245210726, 'mean_word_length': 3.1378763866877972, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2813164', 'n_tokens_mistral': 988, 'n_tokens_neox': 945, 'n_words': 179}