Пример #1
0
class RunTest(unittest.TestCase):
    
    PATCH = {
        'process.cwd': os.path.dirname(__file__),
        'sys.argv': [], #TODO: It's a hack! Replace by normal repatching in methods
    }
    
    def setUp(self):
        self.patcher = Patcher(globals())
        self.patcher.patch(self.PATCH) 
        
    def tearDown(self):
        self.patcher.restore()
    
    def test_run(self):
        sys.argv = ['run', 'function_normal', '1', 'b=test words']
        run()
            
    def test_run_method(self):
        sys.argv = ['run', 'method', '-cClassToRun']
        run()             

    def test_list(self):
        sys.argv = ['run']
        run()
        
    def test_list_methods(self):
        sys.argv = ['run', '-cClassToRun']
        run()            

    def test_help(self):
        sys.argv = ['run', '-h']
        self.assertRaises(SystemExit, run)
            
    def test_help_method(self):
        sys.argv = ['run', 'method', '-cClassToRun', '-h']
        run()             
    
    def test_help_function(self):
        sys.argv = ['run', 'function_normal', '-h']
        run() 
Пример #2
0
class PythonDriverTest(unittest.TestCase):       
      
    PATCH = {
        'subprocess.call': lambda *args, **kwargs: kwargs['env']         
    }
      
    def setUp(self):
        self.patcher = Patcher(globals())
        self.patcher.patch(self.PATCH)
        self.command = Command() 
        self.driver = PythonDriver(self.command)
        
    def tearDown(self):
        self.patcher.restore()
        
    def test_process(self):
        self.assertEqual(self.driver.process(), self.driver._environ)
        
    def test_environ(self):
        self.assertIn('RUN_COMMAND', self.driver._environ)
        self.assertEqual(self.driver._environ['RUN_COMMAND'], {})
        
    def test_connector(self):
        self.assertTrue(self.driver._connector.endswith('.py'))