<commit_before>"""Test suites for virtual environment features."""

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import os
import subprocess
import uuid

import pytest

from venvctrl import api


@pytest.fixture(scope="function")
def random():
    """Get a random UUID."""
    return str(uuid.uuid4())


@pytest.fixture(scope="function")
def venv(random, tmpdir):
    """Get an initialized venv."""
    v = api.VirtualEnvironment(str(tmpdir.join(random)))
    v.create()
    return v


def test_create(random, tmpdir):
    """Test if new virtual environments can be created."""
    path = str(tmpdir.join(random))
    venv = api.VirtualEnvironment(path)
    try:
        venv.create()
    except subprocess.CalledProcessError as exc:
        assert False, exc.stdout
    assert tmpdir.join(random).check()


def test_pip(venv):
    """Test the ability to manage packages with pip."""
    venv.install_package("confpy")
    assert venv.has_package("confpy")
    venv.uninstall_package("confpy")
    assert not venv.has_package("confpy")
    path = os.path.join(venv.path, "..", "requirements.txt")
    with open(path, "w") as req_file:

        req_file.write("confpy{0}".format(os.linesep))

    venv.install_requirements(path)
    assert venv.has_package("confpy")


def test_relocate(venv):<commit_msg>Use backwards compat method to get proc error<commit_after>"""Test suites for virtual environment features."""

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import os
import subprocess
import uuid

import pytest

from venvctrl import api


@pytest.fixture(scope="function")
def random():
    """Get a random UUID."""
    return str(uuid.uuid4())


@pytest.fixture(scope="function")
def venv(random, tmpdir):
    """Get an initialized venv."""
    v = api.VirtualEnvironment(str(tmpdir.join(random)))
    v.create()
    return v


def test_create(random, tmpdir):
    """Test if new virtual environments can be created."""
    path = str(tmpdir.join(random))
    venv = api.VirtualEnvironment(path)
    try:
        venv.create()
    except subprocess.CalledProcessError as exc:
        assert False, exc.output
    assert tmpdir.join(random).check()


def test_pip(venv):
    """Test the ability to manage packages with pip."""
    venv.install_package("confpy")
    assert venv.has_package("confpy")
    venv.uninstall_package("confpy")
    assert not venv.has_package("confpy")
    path = os.path.join(venv.path, "..", "requirements.txt")
    with open(path, "w") as req_file:

        req_file.write("confpy{0}".format(os.linesep))

    venv.install_requirements(path)
    assert venv.has_package("confpy")


def test_relocate(venv):
{'fraction_non_alphanumeric': 0.11929824561403508, 'fraction_numerical': 0.0014035087719298245, 'mean_word_length': 4.127697841726619, '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': '3608899', 'n_tokens_mistral': 898, 'n_tokens_neox': 883, 'n_words': 232}