Beispiel #1
0
 def test_contextmanager(self):
     t = Environment()
     with t(FOOBAR73=1889):
         self.assertEqual(local.python('-c', 'import os;print (os.environ["FOOBAR73"])').splitlines(), ['1889'])
         with t(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"]')
Beispiel #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'))
Beispiel #3
0
 def test_basic(self):
     t = Environment()
     list(t)  # __iter__
     self.assertRaises(TypeError, hash, t)
     len(t)
     self.assertTrue('PATH' in t)
     self.assertFalse('FOOBAR72' in t)
     self.assertRaises(KeyError, lambda: t['FOOBAR72'])
     self.assertRaises(ProcessExecutionError, local.python, '-c', 'import os;os.environ["FOOBAR72"]')
     t['FOOBAR72'] = 'spAm'
     self.assertEqual(local.python('-c', 'import os;print (os.environ["FOOBAR72"])').splitlines(), ['spAm'])
     del t['FOOBAR72']
     t.keys()
     t.items()
     t.values()
     t.get('HOME')
Beispiel #4
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'])