예제 #1
0
def test_read_magic_dir(capfd, tmpdir):
    "Python usage with magic envdir"
    tmp = tmpdir.mkdir("envdir")
    tmp.join("READ_MAGIC").write("test")
    magic_scripts = tmpdir.join("test_magic.py")
    magic_scripts.write("""
import envdir, os, sys
envdir.read()
if 'READ_MAGIC' in os.environ:
    sys.exit(42)
""")
    status = subprocess.call(["python", str(magic_scripts)])
    assert status == 42

    # this should raise a Response with an error because envdir.run()
    # can't have all arguments
    with py.test.raises(SystemExit) as response:
        envdir.run("envdir", str(tmp))
    out, err = capfd.readouterr()

    assert response.value.code == 2
    assert "incorrect number of arguments" in err

    with py.test.raises(SystemExit) as response:
        envdir.run()
    out, err = capfd.readouterr()
    assert response.value.code == 2
예제 #2
0
def test_read_magic_dir(capfd, tmpdir):
    "Python usage with magic envdir"
    tmp = tmpdir.mkdir('envdir')
    tmp.join('READ_MAGIC').write('test')
    magic_scripts = tmpdir.join('test_magic.py')
    magic_scripts.write("""
import envdir, os, sys
envdir.read()
if 'READ_MAGIC' in os.environ:
    sys.exit(42)
""")
    status = subprocess.call(['python', str(magic_scripts)])
    assert status == 42

    # this should raise a Response with an error because envdir.run()
    # can't have all arguments
    with py.test.raises(SystemExit) as response:
        envdir.run('envdir', str(tmp))
    out, err = capfd.readouterr()

    assert response.value.code == 2
    assert "incorrect number of arguments" in err

    with py.test.raises(SystemExit) as response:
        envdir.run()
    out, err = capfd.readouterr()
    assert response.value.code == 2