def _setup_scenario( self, path, include_tests=None, tests=None, files_to_tests=None, exclude_files=None, exclude_tests=None, include_files=None, ): self.MyTestRunner = pydev_runfiles.PydevTestRunner( pydev_runfiles.Configuration( files_or_dirs=path, include_tests=include_tests, verbosity=1, tests=tests, files_to_tests=files_to_tests, exclude_files=exclude_files, exclude_tests=exclude_tests, include_files=include_files, )) self.files = self.MyTestRunner.find_import_files() self.modules = self.MyTestRunner.find_modules_from_files(self.files) self.all_tests = self.MyTestRunner.find_tests_from_modules( self.modules) self.filtered_tests = self.MyTestRunner.filter_tests(self.all_tests)
def test___adjust_python_path_works_for_directories(self): orig_syspath = sys.path tempdir = tempfile.gettempdir() pydev_runfiles.PydevTestRunner( pydev_runfiles.Configuration(files_or_dirs=[tempdir])) self.assertEquals(1, tempdir in sys.path) sys.path = orig_syspath[:]
def run_client(job_id, port, verbosity, coverage_output_file, coverage_include): job_id = int(job_id) import pydev_localhost server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), port)) server.lock = threading.Lock() server_comm = ServerComm(job_id, server) server_comm.start() try: server_facade = ServerFacade(server_comm.notifications_queue) import pydev_runfiles import pydev_runfiles_xml_rpc pydev_runfiles_xml_rpc.SetServer(server_facade) tests_to_run = [1] while tests_to_run: #Investigate: is it dangerous to use the same xmlrpclib server from different threads? #It seems it should be, as it creates a new connection for each request... server.lock.acquire() try: tests_to_run = server.GetTestsToRun(job_id) finally: server.lock.release() if not tests_to_run: break files_to_tests = {} for test in tests_to_run: filename_and_test = test.split('|') if len(filename_and_test) == 2: files_to_tests.setdefault(filename_and_test[0], []).append(filename_and_test[1]) configuration = pydev_runfiles.Configuration( '', verbosity, None, None, None, files_to_tests, 1, None, coverage_output_file=coverage_output_file, coverage_include=coverage_include, ) test_runner = pydev_runfiles.PydevTestRunner(configuration) sys.stdout.flush() test_runner.run_tests() except: traceback.print_exc() server_comm.notifications_queue.put_nowait(KillServer())
del sys.modules['pydev_runfiles'] import pydev_runfiles import unittest import tempfile import re try: set except: from sets import Set as set #this is an early test because it requires the sys.path changed orig_syspath = sys.path a_file = pydev_runfiles.__file__ pydev_runfiles.PydevTestRunner( pydev_runfiles.Configuration(files_or_dirs=[a_file])) file_dir = os.path.dirname(a_file) assert file_dir in sys.path sys.path = orig_syspath[:] #remove it so that we leave it ok for other tests sys.path.remove(desired_runfiles_path) class RunfilesTest(unittest.TestCase): def _setup_scenario( self, path, include_tests=None, tests=None, files_to_tests=None,
def run_client(job_id, port, verbosity, coverage_output_file, coverage_include): job_id = int(job_id) import pydev_localhost server = xmlrpclib.Server('http://%s:%s' % (pydev_localhost.get_localhost(), port)) server.lock = threading.Lock() server_comm = ServerComm(job_id, server) server_comm.start() try: server_facade = ServerFacade(server_comm.notifications_queue) import pydev_runfiles import pydev_runfiles_xml_rpc pydev_runfiles_xml_rpc.SetServer(server_facade) #Starts None and when the 1st test is gotten, it's started (because a server may be initiated and terminated #before receiving any test -- which would mean a different process got all the tests to run). coverage = None try: tests_to_run = [1] while tests_to_run: #Investigate: is it dangerous to use the same xmlrpclib server from different threads? #It seems it should be, as it creates a new connection for each request... server.lock.acquire() try: tests_to_run = server.GetTestsToRun(job_id) finally: server.lock.release() if not tests_to_run: break if coverage is None: _coverage_files, coverage = StartCoverageSupportFromParams( None, coverage_output_file, 1, coverage_include) files_to_tests = {} for test in tests_to_run: filename_and_test = test.split('|') if len(filename_and_test) == 2: files_to_tests.setdefault(filename_and_test[0], []).append( filename_and_test[1]) configuration = pydev_runfiles.Configuration( '', verbosity, None, None, None, files_to_tests, 1, #Always single job here None, #The coverage is handled in this loop. coverage_output_file=None, coverage_include=None, ) test_runner = pydev_runfiles.PydevTestRunner(configuration) sys.stdout.flush() test_runner.run_tests(handle_coverage=False) finally: if coverage is not None: coverage.stop() coverage.save() except: traceback.print_exc() server_comm.notifications_queue.put_nowait(KillServer())