コード例 #1
0
ファイル: plugin.py プロジェクト: lalinsky/nosexunit
 def options(self, parser, env=os.environ):
     '''Add launch options for NoseXUnit'''
     # Call super
     Plugin.options(self, parser, env)
     # ---------------------------------------------------------------------
     # CORE
     # ---------------------------------------------------------------------
     # Add test target folder
     parser.add_option('--core-target',
                       action='store',
                       default = nconst.TARGET_CORE,
                       dest='core_target',
                       help='Output folder for test reports (default is %s).' % nconst.TARGET_CORE)
     # Add source folder
     parser.add_option('--source-folder',
                       action='store',
                       default=None,
                       dest='source',
                       help='Set source folder (optional for core functionality, required for audit and coverage). Add folder in sys.path.')
     # Search sources in source tree
     parser.add_option('--search-source',
                       action='store_true',
                       default=False,
                       dest='search_source',
                       help="Walk in the source folder to add deeper folders in sys.path if they don't contain __init__.py file. Works only if --source-folder is defined.")
     # Search tests in 
     parser.add_option('--search-test',
                       action='store_true',
                       default=False,
                       dest='search_test',
                       help='Search tests in folders with no __init__.py file (default: do nothing).')
     # Package to process in audit or coverage extensions
     parser.add_option('--extra-include',
                       action='append',
                       default=[],
                       dest='extra_includes',
                       help='Include packages for audit or coverage processing (default: take all packages in --source-folder, except those defined in --extra-exclude). Package name specified with regex.')
     # Package to do not process in audit or coverage extensions
     parser.add_option('--extra-exclude',
                       action='append',
                       default=nconst.AUDIT_COVER_EXCLUDE,
                       dest='extra_excludes',
                       help='Exclude packages for audit or coverage processing (default: %s). Useless if --extra-include defined. Package name specified with regex.' % (', '.join(nconst.AUDIT_COVER_EXCLUDE), ))
     # Package to do not process in audit or coverage extensions
     parser.add_option('--extra-test-process',
                       action='store_true',
                       default=False,
                       dest='extra_test_process',
                       help='Include packages matching the test pattern in audit or coverage processing (default: no).')
     # ---------------------------------------------------------------------
     # AUDIT
     # ---------------------------------------------------------------------
     # Add option to enable audit
     parser.add_option('--enable-audit',
                       action='store_true',
                       default=False,
                       dest='audit',
                       help='Use PyLint to audit source code (default: no)')        
     # Add PyLint target folder
     parser.add_option('--audit-target',
                       action='store',
                       default=nconst.TARGET_AUDIT,
                       dest='audit_target',
                       help='Output folder for PyLint reports (default is %s).' % nconst.TARGET_AUDIT)
     # Add PyLint output
     parser.add_option('--audit-output',
                       action='store',
                       default=nconst.AUDIT_DEFAULT_REPORTER,
                       dest='audit_output',
                       help='Output for audit reports: %s (default: %s).' % (', '.join(naudit.outputs()), nconst.AUDIT_DEFAULT_REPORTER))
     # Add PyLint configuration file
     parser.add_option('--audit-config',
                       action='store',
                       default=None,
                       dest='audit_config',
                       help='Configuration file for PyLint (optional).')
     # ---------------------------------------------------------------------
     # COVER
     # ---------------------------------------------------------------------
     # Add option to enable coverage
     parser.add_option('--enable-cover',
                       action='store_true',
                       default=False,
                       dest='cover',
                       help='Use coverage to audit source code (default: no)')        
     # Add coverage target folder
     parser.add_option('--cover-target',
                       action='store',
                       default = nconst.TARGET_COVER,
                       dest='cover_target',
                       help='Output folder for coverage reports (default is %s).' % nconst.TARGET_COVER)
     # Check if clean folder
     parser.add_option('--cover-clean',
                       action='store_true',
                       default=False,
                       dest='cover_clean',
                       help='Clean previous coverage results (default: no).')
     # Collect extra coverage files in target folder
     parser.add_option('--cover-collect',
                       action='store_true',
                       default=False,
                       dest='cover_collect',
                       help='Collect other coverage files potentially generated in cover target folder. These extra files should have the following pattern: %s.* (default: no).' % nconst.COVER_OUTPUT_BASE)
コード例 #2
0
ファイル: plugin.py プロジェクト: Xotabu4/NoseXUnitPy3
 def options(self, parser, env=os.environ):
     '''Add launch options for NoseXUnit'''
     # Call super
     Plugin.options(self, parser, env)
     # ---------------------------------------------------------------------
     # CORE
     # ---------------------------------------------------------------------
     # Add test target folder
     parser.add_option(
         '--core-target',
         action='store',
         default=nconst.TARGET_CORE,
         dest='core_target',
         help='Output folder for test reports (default is %s).' %
         nconst.TARGET_CORE)
     # Add source folder
     parser.add_option(
         '--source-folder',
         action='store',
         default=None,
         dest='source',
         help=
         'Set source folder (optional for core functionality, required for audit and coverage). Add folder in sys.path.'
     )
     # Search sources in source tree
     parser.add_option(
         '--search-source',
         action='store_true',
         default=False,
         dest='search_source',
         help=
         "Walk in the source folder to add deeper folders in sys.path if they don't contain __init__.py file. Works only if --source-folder is defined."
     )
     # Search tests in
     parser.add_option(
         '--search-test',
         action='store_true',
         default=False,
         dest='search_test',
         help=
         'Search tests in folders with no __init__.py file (default: do nothing).'
     )
     # Package to process in audit or coverage extensions
     parser.add_option(
         '--extra-include',
         action='append',
         default=[],
         dest='extra_include',
         help=
         'Include packages for audit or coverage processing (default: take all packages in --source-folder, except those defined in --extra-exclude).'
     )
     # Package to do not process in audit or coverage extensions
     parser.add_option(
         '--extra-exclude',
         action='append',
         default=nconst.AUDIT_COVER_EXCLUDE,
         dest='extra_exclude',
         help=
         'Exclude packages for audit or coverage processing (default: %s). Useless if --extra-include defined.'
         % (', '.join(nconst.AUDIT_COVER_EXCLUDE), ))
     # Package to do not process in audit or coverage extensions
     parser.add_option(
         '--extra-test-process',
         action='store_true',
         default=False,
         dest='extra_test_process',
         help=
         'Include packages matching the test pattern in audit or coverage processing (default: no).'
     )
     # ---------------------------------------------------------------------
     # AUDIT
     # ---------------------------------------------------------------------
     # Add option to enable audit
     parser.add_option('--enable-audit',
                       action='store_true',
                       default=False,
                       dest='audit',
                       help='Use PyLint to audit source code (default: no)')
     # Add PyLint target folder
     parser.add_option(
         '--audit-target',
         action='store',
         default=nconst.TARGET_AUDIT,
         dest='audit_target',
         help='Output folder for PyLint reports (default is %s).' %
         nconst.TARGET_AUDIT)
     # Add PyLint output
     parser.add_option(
         '--audit-output',
         action='store',
         default=nconst.AUDIT_DEFAULT_REPORTER,
         dest='audit_output',
         help='Output for audit reports: %s (default: %s).' %
         (', '.join(naudit.outputs()), nconst.AUDIT_DEFAULT_REPORTER))
     # Add PyLint configuration file
     parser.add_option('--audit-config',
                       action='store',
                       default=None,
                       dest='audit_config',
                       help='Configuration file for PyLint (optional).')
     # ---------------------------------------------------------------------
     # COVER
     # ---------------------------------------------------------------------
     # Add option to enable coverage
     parser.add_option(
         '--enable-cover',
         action='store_true',
         default=False,
         dest='cover',
         help='Use coverage to audit source code (default: no)')
     # Add coverage target folder
     parser.add_option(
         '--cover-target',
         action='store',
         default=nconst.TARGET_COVER,
         dest='cover_target',
         help='Output folder for coverage reports (default is %s).' %
         nconst.TARGET_COVER)
     # Check if clean folder
     parser.add_option(
         '--cover-clean',
         action='store_true',
         default=False,
         dest='cover_clean',
         help='Clean previous coverage results (default: no).')
     # Collect extra coverage files in target folder
     parser.add_option(
         '--cover-collect',
         action='store_true',
         default=False,
         dest='cover_collect',
         help=
         'Collect other coverage files potentially generated in cover target folder. These extra files should have the following pattern: %s.* (default: no).'
         % nconst.COVER_OUTPUT_BASE)
コード例 #3
0
ファイル: plugin.py プロジェクト: lalinsky/nosexunit
 def initialize(self):
     '''Set the environment'''
     # Check that source folder exists if specified
     if self.source and not os.path.isdir(self.source):
         # Source folder doesn't exist
         raise nexcepts.NoseXUnitError("source folder doesn't exist: %s" % self.source)
     # Create the core target folder
     ntools.create(self.core_target)
     # Clean the target folder of the core
     ntools.clean(self.core_target, nconst.PREFIX_CORE, nconst.EXT_CORE)
     # Initialize the packages
     self.packages = {}
     # Add the source folder in the path
     if self.source:
         # Get the packages
         self.packages = ntools.packages(self.source, search=self.search_source)
         # Get the folders to add in the path
         folders = []
         # Go threw the packages
         for package in self.packages.keys():
             # Check if is as sub package or a sub module
             if package.find('.') == -1:
                 # Get the folder
                 folder = os.path.dirname(self.packages[package])
                 # If not already in, add it
                 if folder not in folders: folders.append(folder)
         # Get current path
         backup = sys.path
         # Clean up
         sys.path = []
         # Add to the path
         for folder in folders:
             # Log
             logger.info('add folder in sys.path: %s' % folder)
             # Add to the path
             sys.path.append(folder)
         # Add old ones
         sys.path.extend(backup)
     # Check if audit enabled
     if self.audit:
         # Check if source folder specified
         if not self.source: raise nexcepts.NoseXUnitError('source folder required for audit')
         # Check output
         if self.audit_output not in naudit.outputs(): raise nexcepts.NoseXUnitError('output not available for audit: %s' % self.audit_output)
         # Create the target folder for audit
         ntools.create(self.audit_target)
         # Get the package list for audit
         self.audit_packages = [ package for package in self.packages.keys() if package.find('.') == -1 and self.enable(package) ]
         # Check at least one
         if self.audit_packages == []: raise nexcepts.NoseXUnitError('no package to audit')
         # Start audit
         self.audit_cls = naudit.audit(self.source, self.audit_packages, self.audit_output, self.audit_target, self.audit_config)
     # No test class
     else: self.audit_cls = []
     # Check if coverage enabled
     if self.cover:
         # Check if source folder specified
         if not self.source: raise nexcepts.NoseXUnitError('source folder required for coverage')
         # Create the target folder for audit
         ntools.create(self.cover_target)
         # Get the skipped ones
         self.skipped = sys.modules.keys()[:]
         # Get the coverage packages
         self.cover_packages = [ package for package in self.packages.keys() if self.enable(package) ]
         # Check at least one
         if self.cover_packages == []: raise nexcepts.NoseXUnitError('no package to cover')
         # Start coverage
         ncover.start(self.cover_clean, self.cover_packages, self.cover_target)
コード例 #4
0
ファイル: plugin.py プロジェクト: Xotabu4/NoseXUnitPy3
 def initialize(self):
     '''Set the environment'''
     # Check that source folder exists if specified
     if self.source and not os.path.isdir(self.source):
         # Source folder doesn't exist
         raise nexcepts.NoseXUnitError("source folder doesn't exist: %s" %
                                       self.source)
     # Create the core target folder
     ntools.create(self.core_target)
     # Clean the target folder of the core
     ntools.clean(self.core_target, nconst.PREFIX_CORE, nconst.EXT_CORE)
     # Initialize the packages
     self.packages = {}
     # Add the source folder in the path
     if self.source:
         # Get the packages
         self.packages = ntools.packages(self.source,
                                         search=self.search_source)
         # Get the folders to add in the path
         folders = []
         # Go threw the packages
         for package in list(self.packages.keys()):
             # Check if is as sub package or a sub module
             if package.find('.') == -1:
                 # Get the folder
                 folder = os.path.dirname(self.packages[package])
                 # If not already in, add it
                 if folder not in folders: folders.append(folder)
         # Get current path
         backup = sys.path
         # Clean up
         sys.path = []
         # Add to the path
         for folder in folders:
             # Log
             logger.info('add folder in sys.path: %s' % folder)
             # Add to the path
             sys.path.append(folder)
         # Add old ones
         sys.path.extend(backup)
     # Check if audit enabled
     if self.audit:
         # Check if source folder specified
         if not self.source:
             raise nexcepts.NoseXUnitError(
                 'source folder required for audit')
         # Check output
         if self.audit_output not in naudit.outputs():
             raise nexcepts.NoseXUnitError(
                 'output not available for audit: %s' % self.audit_output)
         # Create the target folder for audit
         ntools.create(self.audit_target)
         # Get the package list for audit
         self.audit_packages = [
             package for package in list(self.packages.keys())
             if package.find('.') == -1 and self.enable(package)
         ]
         # Check at least one
         if self.audit_packages == []:
             raise nexcepts.NoseXUnitError('no package to audit')
         # Start audit
         self.audit_cls = naudit.audit(self.source, self.audit_packages,
                                       self.audit_output, self.audit_target,
                                       self.audit_config)
     # No test class
     else:
         self.audit_cls = []
     # Check if coverage enabled
     if self.cover:
         # Check if source folder specified
         if not self.source:
             raise nexcepts.NoseXUnitError(
                 'source folder required for coverage')
         # Create the target folder for audit
         ntools.create(self.cover_target)
         # Get the skipped ones
         self.skipped = list(sys.modules.keys())[:]
         # Get the coverage packages
         self.cover_packages = [
             package for package in list(self.packages.keys())
             if self.enable(package)
         ]
         # Check at least one
         if self.cover_packages == []:
             raise nexcepts.NoseXUnitError('no package to cover')
         # Start coverage
         ncover.start(self.cover_clean, self.cover_packages,
                      self.cover_target)