-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
putting the pieces in place to inject environment variables
- Loading branch information
1 parent
2764afc
commit a97d4e6
Showing
3 changed files
with
78 additions
and
1 deletion.
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
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,44 @@ | ||
import os | ||
import tempfile | ||
from nose.tools import ok_ | ||
from uranium.virtualenv_manager import inject_into_file | ||
|
||
|
||
class TestInjectIntoFile(object): | ||
|
||
def setUp(self): | ||
_, self.temp_file = tempfile.mkstemp() | ||
|
||
def tearDown(self): | ||
os.unlink(self.temp_file) | ||
|
||
def test_inject_empty_file(self): | ||
inject_into_file(self.temp_file, "foo") | ||
with open(self.temp_file) as fh: | ||
ok_("foo" in fh.read()) | ||
|
||
def test_inject_twice(self): | ||
""" | ||
injecting twice should only result | ||
in the latest entry in the file. | ||
""" | ||
inject_into_file(self.temp_file, "foo") | ||
inject_into_file(self.temp_file, "boo") | ||
|
||
with open(self.temp_file) as fh: | ||
content = fh.read() | ||
|
||
ok_("foo" not in content) | ||
ok_("boo" in content) | ||
|
||
def test_injection_with_content(self): | ||
with open(self.temp_file, 'w+') as fh: | ||
fh.write("this is already in here") | ||
|
||
inject_into_file(self.temp_file, "foo") | ||
|
||
with open(self.temp_file) as fh: | ||
content = fh.read() | ||
|
||
ok_("this is already in here" in content) | ||
ok_("foo" in content) |
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