def testTwistedLoads(self): # NOTE: Update this if 'twisted' version changes. with env.GetInfraPythonPath().Enter(): import twisted self.assertEqual( env.SplitPath(twisted.__file__)[-4:-1], ['third_party', 'twisted_10_2', 'twisted'])
def testRequestsLoads(self): # NOTE: Update this if 'requests' version changes. with env.GetInfraPythonPath().Enter(): import requests self.assertEqual( env.SplitPath(requests.__file__)[-4:-1], ['third_party', 'requests_1_2_3', 'requests'])
def MasterEnvironment(master_dir): """Context manager that enters an enviornment similar to a master's. This involves: - Modifying 'sys.path' to include paths available to the master. - Changing directory (via os.chdir()) to the master's base directory. These changes will be reverted after the context manager completes. Args: master_dir: (str) The master's base directory. """ master_dir = os.path.abspath(master_dir) # Setup a 'sys.path' that is adequate for loading 'slaves.cfg'. old_cwd = os.getcwd() with env.GetInfraPythonPath(master_dir=master_dir).Enter(): try: os.chdir(master_dir) yield finally: os.chdir(old_cwd)
def testGenerate(self): self.assertIsNotNone(env.GetInfraPythonPath(hermetic=True)) self.assertIsNotNone(env.GetInfraPythonPath(hermetic=False)) self.assertIsNotNone( env.GetInfraPythonPath(master_dir=os.path.join( env.Build, 'masters', 'master.chromium')))