Exemplo n.º 1
0
 def test_run_command_with_env(self):
     connector = BaseCommandDBConnector()
     # Empty env
     stdout, stderr = connector.run_command('env')
     self.assertFalse(stdout.read())
     # env from self.env
     connector.env = {'foo': 'bar'}
     stdout, stderr = connector.run_command('env')
     self.assertEqual(stdout.read(), b'foo=bar\n')
     # method overide gloabal env
     stdout, stderr = connector.run_command('env', env={'foo': 'ham'})
     self.assertEqual(stdout.read(), b'foo=ham\n')
 def test_run_command_with_env(self):
     connector = BaseCommandDBConnector()
     # Empty env
     stdout, stderr = connector.run_command('env')
     self.assertTrue(stdout.read())
     # env from self.env
     connector.env = {'foo': 'bar'}
     stdout, stderr = connector.run_command('env')
     self.assertIn(b'foo=bar\n', stdout.read())
     # method overide gloabal env
     stdout, stderr = connector.run_command('env', env={'foo': 'ham'})
     self.assertIn(b'foo=ham\n', stdout.read())
     # get a var from parent env
     os.environ['bar'] = 'foo'
     stdout, stderr = connector.run_command('env')
     self.assertIn(b'bar=foo\n', stdout.read())
     # Conf overides parendt env
     connector.env = {'bar': 'bar'}
     stdout, stderr = connector.run_command('env')
     self.assertIn(b'bar=bar\n', stdout.read())
     # method overides all
     stdout, stderr = connector.run_command('env', env={'bar': 'ham'})
     self.assertIn(b'bar=ham\n', stdout.read())
Exemplo n.º 3
0
 def test_run_command_with_env(self):
     connector = BaseCommandDBConnector()
     # Empty env
     stdout, stderr = connector.run_command('env')
     self.assertTrue(stdout.read())
     # env from self.env
     connector.env = {'foo': 'bar'}
     stdout, stderr = connector.run_command('env')
     self.assertIn(b'foo=bar\n', stdout.read())
     # method overide gloabal env
     stdout, stderr = connector.run_command('env', env={'foo': 'ham'})
     self.assertIn(b'foo=ham\n', stdout.read())
     # get a var from parent env
     os.environ['bar'] = 'foo'
     stdout, stderr = connector.run_command('env')
     self.assertIn(b'bar=foo\n', stdout.read())
     # Conf overides parendt env
     connector.env = {'bar': 'bar'}
     stdout, stderr = connector.run_command('env')
     self.assertIn(b'bar=bar\n', stdout.read())
     # method overides all
     stdout, stderr = connector.run_command('env', env={'bar': 'ham'})
     self.assertIn(b'bar=ham\n', stdout.read())
 def test_run_command_with_parent_env(self):
     connector = BaseCommandDBConnector(use_parent_env=False)
     # Empty env
     stdout, stderr = connector.run_command('env')
     self.assertFalse(stdout.read())
     # env from self.env
     connector.env = {'foo': 'bar'}
     stdout, stderr = connector.run_command('env')
     self.assertEqual(stdout.read(), b'foo=bar\n')
     # method overide gloabal env
     stdout, stderr = connector.run_command('env', env={'foo': 'ham'})
     self.assertEqual(stdout.read(), b'foo=ham\n')
     # no var from parent env
     os.environ['bar'] = 'foo'
     stdout, stderr = connector.run_command('env')
     self.assertNotIn(b'bar=foo\n', stdout.read())
Exemplo n.º 5
0
 def test_run_command_with_parent_env(self):
     connector = BaseCommandDBConnector(use_parent_env=False)
     # Empty env
     stdout, stderr = connector.run_command('env')
     self.assertFalse(stdout.read())
     # env from self.env
     connector.env = {'foo': 'bar'}
     stdout, stderr = connector.run_command('env')
     self.assertEqual(stdout.read(), b'foo=bar\n')
     # method overide gloabal env
     stdout, stderr = connector.run_command('env', env={'foo': 'ham'})
     self.assertEqual(stdout.read(), b'foo=ham\n')
     # no var from parent env
     os.environ['bar'] = 'foo'
     stdout, stderr = connector.run_command('env')
     self.assertNotIn(b'bar=foo\n', stdout.read())