-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding cd context handling tests and fixing some absolute path issues
- Loading branch information
Showing
3 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os | ||
|
||
from pie import * | ||
|
||
|
||
@task | ||
def cdContext(): | ||
with cd('..'): | ||
print(os.getcwd()) | ||
print(os.getcwd()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize('pie_tasks_path',['venv_context'],indirect=['pie_tasks_path']) | ||
def test_venv_context(pie,pie_tasks_path,pie_mock_cmd): | ||
pie.main(['venvContext']) | ||
cwd=os.getcwd() | ||
first_activate=r'{}\first\Scripts\activate.bat'.format(cwd) | ||
second_activate=r'{}\second\Scripts\activate.bat'.format(cwd) | ||
# TODO: only correct on Windows | ||
assert len(pie_mock_cmd.cmds)==1 | ||
assert pie_mock_cmd.cmds[0][0][0]==r'cmd /c "first\Scripts\activate.bat && cmd /c "second\Scripts\activate.bat && blah""' | ||
assert pie_mock_cmd.cmds[0][0][0]==r'cmd /c "{} && cmd /c "{} && blah""'.format(first_activate,second_activate) | ||
|
||
|
||
@pytest.mark.parametrize('pie_tasks_path',['cd_context'],indirect=['pie_tasks_path']) | ||
def test_cd_context(pie,capsys,pie_tasks_path,pie_mock_cmd): | ||
pie.main(['cdContext']) | ||
cwd=os.getcwd() | ||
assert len(pie_mock_cmd.cmds)==0 | ||
out,err=capsys.readouterr() | ||
assert out=='{}\n{}\n'.format(os.path.dirname(cwd),cwd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters