Exemple #1
0
 def test_as_fn(self):
     "Should work as a callable"
     nix.cd('/tmp')
     cwd = os.getcwd()
     if sys.platform == 'darwin':
         cwd = cwd.replace('/private', '')
     self.assertEqual('/tmp', cwd)
Exemple #2
0
 def test_accepts_path(self):
     "Should Duck-type with Path objects"
     nix.cd(Path('/tmp'))
     cwd = os.getcwd()
     if sys.platform == 'darwin':
         cwd = cwd.replace('/private', '')
     self.assertEqual('/tmp', cwd)
Exemple #3
0
 def test_accepts_path(self):
     "Should Duck-type with Path objects"
     nix.cd(Path('/tmp'))
     cwd = os.getcwd()
     if sys.platform == 'darwin':
         cwd = cwd.replace('/private', '')        
     self.assertEqual('/tmp', cwd)
Exemple #4
0
 def test_as_fn(self):
     "Should work as a callable"
     nix.cd('/tmp')
     cwd = os.getcwd()
     if sys.platform == 'darwin':
         cwd = cwd.replace('/private', '')
     self.assertEqual('/tmp', cwd)
Exemple #5
0
 def test_contextmanager(self):
     "Should work as a contextmanager"
     with nix.cd('/tmp') as path:
         cwd = os.getcwd()
         if sys.platform == 'darwin':
             cwd = cwd.replace('/private', '')
         self.assertEqual('/tmp', cwd)
         self.assertIsInstance(path, Path)
         self.assertEqual('/tmp', path)
     self.assertEqual(self.startdir, os.getcwd())
Exemple #6
0
 def test_contextmanager(self):
     "Should work as a contextmanager"
     with nix.cd('/tmp') as path:
         cwd = os.getcwd()
         if sys.platform == 'darwin':
             cwd = cwd.replace('/private', '')
         self.assertEqual('/tmp', cwd)
         self.assertIsInstance(path, Path)
         self.assertEqual('/tmp', path)
     self.assertEqual(self.startdir, os.getcwd())
Exemple #7
0
 def test_contextmanager_raises(self):
     "Should propagate exceptions"
     with self.assertRaises(RuntimeError):
         with nix.cd('/tmp'):
             raise RuntimeError('!')
     self.assertEqual(self.startdir, os.getcwd())
Exemple #8
0
 def cd(self, target):
     return nix.cd(target)
Exemple #9
0
 def test_contextmanager_raises(self):
     "Should propagate exceptions"
     with self.assertRaises(RuntimeError):
         with nix.cd('/tmp'):
             raise RuntimeError('!')
     self.assertEqual(self.startdir, os.getcwd())