forked from b-ryan/powerline-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request b-ryan#194 from b-ryan/master
Fix for following symbolic links, plus start testing things
- Loading branch information
Showing
5 changed files
with
78 additions
and
18 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
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,2 @@ | ||
nose | ||
mock |
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
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,53 @@ | ||
import unittest | ||
import mock | ||
import os | ||
import tempfile | ||
import shutil | ||
import powerline_shell_base as p | ||
|
||
|
||
class CwdTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.dirname = tempfile.mkdtemp() | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.dirname) | ||
|
||
@mock.patch('os.getenv') | ||
@mock.patch('powerline_shell_base.warn') | ||
def test_normal(self, warn, getenv): | ||
getenv.return_value = self.dirname | ||
self.assertEqual(p.get_valid_cwd(), self.dirname) | ||
self.assertEqual(warn.call_count, 0) | ||
|
||
@mock.patch('os.getenv') | ||
@mock.patch('powerline_shell_base.warn') | ||
def test_nonexistent_warns(self, warn, getenv): | ||
subdir = os.path.join(self.dirname, 'subdir') | ||
getenv.return_value = subdir | ||
self.assertEqual(p.get_valid_cwd(), subdir) | ||
self.assertEqual(warn.call_count, 1) | ||
|
||
@mock.patch('os.getenv') | ||
@mock.patch('powerline_shell_base.warn') | ||
def test_falls_back_to_getcwd(self, warn, getenv): | ||
getenv.return_value = None | ||
os.chdir(self.dirname) | ||
self.assertEqual(p.get_valid_cwd(), self.dirname) | ||
self.assertEqual(warn.call_count, 0) | ||
|
||
@mock.patch('os.getenv') | ||
@mock.patch('powerline_shell_base.warn') | ||
def test_nonexistent_getcwd_warns(self, warn, getenv): | ||
subdir = os.path.join(self.dirname, 'subdir') | ||
getenv.return_value = None | ||
|
||
os.mkdir(subdir) | ||
os.chdir(subdir) | ||
os.rmdir(subdir) | ||
|
||
with self.assertRaises(SystemExit) as e: | ||
p.get_valid_cwd() | ||
|
||
self.assertEqual(warn.call_count, 1) |