示例#1
0
def test_classify_shell():
    cmd = classify(lines=["$ py.test -x\n", "crud\n"])
    expected = {
        "action": "shell",
        "cwd": None,
        "target": "py.test -x",
        "content": "crud\n",
        "indent": 4,
        "line": None,
    }
    assert cmd == expected
示例#2
0
def test_classify_shell(fake_file: Path) -> None:
    cmd = classify(lines=["$ py.test -x\n", "crud\n"], file=fake_file)
    expected = Action(
        command=process,
        cwd=None,
        target="py.test -x",
        content="crud\n",
        indent=0,
        line=0,
        file=fake_file,
    )
    assert cmd == expected
示例#3
0
def test_classify_chdir_shell():
    cmd = classify(lines=["testing $ echo hi\n", "crud\n"])

    expected = {
        "action": "shell",
        "cwd": "testing",
        "target": "echo hi",
        "content": "crud\n",
        "indent": 4,
        "line": None,
    }

    assert cmd == expected
示例#4
0
def test_classify_write():

    write = classify(["# content of test_foo.py\n", "def test()\n", "    pass\n"])

    expected = {
        "action": "write",
        "cwd": None,
        "target": "test_foo.py",
        "content": "def test()\n    pass\n",
        "indent": 4,
        "line": None,
    }
    assert write == expected
示例#5
0
def test_classify_chdir_shell(fake_file: Path) -> None:
    cmd = classify(lines=["testing $ echo hi\n", "crud\n"], file=fake_file)

    expected = Action(
        command=process,
        cwd=Path("testing"),
        target="echo hi",
        content="crud\n",
        indent=0,
        line=0,
        file=fake_file,
    )

    assert cmd == expected
示例#6
0
def test_classify_write(fake_file: Path) -> None:

    write_result = classify(
        ["# content of test_foo.py\n", "def test()\n", "    pass\n"],
        file=fake_file)

    expected = Action(
        command=write,
        cwd=None,
        target="test_foo.py",
        content="def test()\n    pass\n",
        indent=0,
        line=0,
        file=fake_file,
    )
    assert write_result == expected