<commit_before>from sys import platform
from subprocess import check_call
from pathlib import Path

from pew._utils import invoke_pew as invoke
from utils import skip_windows, xfail_nix

import pytest

which_cmd = 'where' if platform == 'win32' else 'which'

pytestmark = skip_windows(
    reason='temporarily disable tests, due to issues with the virtualenv-clone'
    ' executable, maybe this bug? http://bugs.python.org/issue20614'
)


@pytest.yield_fixture()
def copied_env(workon_home, env1):
    invoke('cp', 'env1', 'destination', '-d')
    yield workon_home / 'destination'
    invoke('rm', 'destination')


@xfail_nix
def test_new_env_activated(workon_home, testpackageenv):
    invoke('cp', 'source', 'destination', '-d')
    testscript = Path(invoke('in', 'destination', which_cmd, 'testscript.py').out.strip())
    assert ('destination', 'testscript.py') == (testscript.parts[-3], testscript.parts[-1])
    with testscript.open() as f:
        assert str(workon_home / 'destination') in f.read()
    invoke('rm', 'destination')


def test_virtualenv_variable(copied_env):
    envname = invoke('workon', copied_env.name, inp='echo $VIRTUAL_ENV').out.strip()
    assert str(copied_env) == envname


@xfail_nix
def test_source_relocatable(workon_home, testpackageenv):
    check_call(['virtualenv', '--relocatable', str(workon_home / 'source')])<commit_msg>Use -m to run virtualenv in tests as well<commit_after>from sys import platform, executable
from subprocess import check_call
from pathlib import Path

from pew._utils import invoke_pew as invoke
from utils import skip_windows, xfail_nix

import pytest

which_cmd = 'where' if platform == 'win32' else 'which'

pytestmark = skip_windows(
    reason='temporarily disable tests, due to issues with the virtualenv-clone'
    ' executable, maybe this bug? http://bugs.python.org/issue20614'
)


@pytest.yield_fixture()
def copied_env(workon_home, env1):
    invoke('cp', 'env1', 'destination', '-d')
    yield workon_home / 'destination'
    invoke('rm', 'destination')


@xfail_nix
def test_new_env_activated(workon_home, testpackageenv):
    invoke('cp', 'source', 'destination', '-d')
    testscript = Path(invoke('in', 'destination', which_cmd, 'testscript.py').out.strip())
    assert ('destination', 'testscript.py') == (testscript.parts[-3], testscript.parts[-1])
    with testscript.open() as f:
        assert str(workon_home / 'destination') in f.read()
    invoke('rm', 'destination')


def test_virtualenv_variable(copied_env):
    envname = invoke('workon', copied_env.name, inp='echo $VIRTUAL_ENV').out.strip()
    assert str(copied_env) == envname


@xfail_nix
def test_source_relocatable(workon_home, testpackageenv):
    check_call([executable, '-m', 'virtualenv', '--relocatable',
                str(workon_home / 'source')])
{'fraction_non_alphanumeric': 0.13578047042052743, 'fraction_numerical': 0.007840342124019958, 'mean_word_length': 4.997863247863248, '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': '3661431', 'n_tokens_mistral': 930, 'n_tokens_neox': 903, 'n_words': 226}