Exemple #1
0
 def test_path(self):
     t = Environment()
     self.assertRaises(CommandNotFound, local.which, 'dummy-executable')
     self.assertTrue('foobar' != t['HOME'])
     with t():
         t['HOME'] = 'foobar'
         path = local.cwd / 'tests' / 'not-in-path'
         t.path.insert(0, path)
         self.assertEqual(path / 'dummy-executable', local.which('dummy-executable'))
     self.assertTrue('foobar' != t['HOME'])
Exemple #2
0
 def test_env(self):
     self.assertTrue('PATH' in local.env)
     self.assertFalse('FOOBAR72' in local.env)
     self.assertRaises(ProcessExecutionError, local.python, '-c', 'import os;os.environ["FOOBAR72"]')
     local.env['FOOBAR72'] = 'spAm'
     self.assertEqual(local.python('-c', 'import os;print (os.environ["FOOBAR72"])').splitlines(), ['spAm'])
     with local.env(FOOBAR73=1889):
         self.assertEqual(local.python('-c', 'import os;print (os.environ["FOOBAR73"])').splitlines(), ['1889'])
         with local.env(FOOBAR73=1778):
             self.assertEqual(local.python('-c', 'import os;print (os.environ["FOOBAR73"])').splitlines(), ['1778'])
         self.assertEqual(local.python('-c', 'import os;print (os.environ["FOOBAR73"])').splitlines(), ['1889'])
     self.assertRaises(ProcessExecutionError, local.python, '-c', 'import os;os.environ["FOOBAR73"]')
     # path manipulation
     self.assertRaises(CommandNotFound, local.which, 'dummy-executable')
     with local.env():
         path = local.cwd / 'not-in-path'
         local.env.path.insert(0, path)
         self.assertEqual(path / 'dummy-executable', local.which('dummy-executable'))
Exemple #3
0
 def test_local(self):
     self.assertTrue('cuprum' in str(local.cwd))
     self.assertTrue('PATH' in local.env.as_dict())
     local.which('ls')
     local['ls']
     self.assertEqual(local.python('-c', 'print ("hi there")').splitlines(), ['hi there'])