コード例 #1
0
ファイル: test_packages.py プロジェクト: Xotabu4/NoseXUnitPy3
 def test_search(self):
     f = test_NoseXUnit.Folder('folder')
     m = test_NoseXUnit.Module('foo')
     f.append(m)
     f.save(self.source)
     expected = {m.desc(): m.path(), }
     self.assertEqual(expected, ntools.packages(self.source, search=True, exclude=[]))
コード例 #2
0
ファイル: test_packages.py プロジェクト: lalinsky/nosexunit
 def test_search(self):
     f = test_NoseXUnit.Folder('folder')
     m = test_NoseXUnit.Module('foo')
     f.append(m)
     f.save(self.source)
     expected = {m.desc(): m.path(), }
     self.assertEquals(expected, ntools.packages(self.source, search=True, exclude=[]))
コード例 #3
0
ファイル: test_packages.py プロジェクト: Xotabu4/NoseXUnitPy3
 def test_package_module(self):
     p = test_NoseXUnit.Package('foo_1')
     m = test_NoseXUnit.Module('foo_2')
     p.append(m)
     p.save(self.source)
     expected = {p.full(): p.path(),
                 m.full(): m.path(), }
     self.assertEqual(expected, ntools.packages(self.source, search=True, exclude=[]))
コード例 #4
0
ファイル: test_packages.py プロジェクト: lalinsky/nosexunit
 def test_package_module(self):
     p = test_NoseXUnit.Package('foo_1')
     m = test_NoseXUnit.Module('foo_2')
     p.append(m)
     p.save(self.source)
     expected = {p.full(): p.path(),
                 m.full(): m.path(), }
     self.assertEquals(expected, ntools.packages(self.source, search=True, exclude=[]))
コード例 #5
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)
コード例 #6
0
ファイル: test_packages.py プロジェクト: Xotabu4/NoseXUnitPy3
 def test_package(self):
     p = test_NoseXUnit.Package('foo').save(self.source)
     expected = {'foo': p.path(), }
     self.assertEqual(expected, ntools.packages(self.source, search=False, exclude=[]))
コード例 #7
0
ファイル: test_packages.py プロジェクト: Xotabu4/NoseXUnitPy3
 def test_exclude(self):
     f = test_NoseXUnit.Folder('CVS')
     m = test_NoseXUnit.Module('foo')
     f.append(m)
     f.save(self.source)
     self.assertEqual({}, ntools.packages(self.source, search=True, exclude=['CVS', ]))
コード例 #8
0
ファイル: test_packages.py プロジェクト: Xotabu4/NoseXUnitPy3
 def test_no_search(self):
     f = test_NoseXUnit.Folder('folder')
     m = test_NoseXUnit.Module('foo')
     f.append(m)
     f.save(self.source)
     self.assertEqual({}, ntools.packages(self.source, search=False, exclude=[]))
コード例 #9
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)
コード例 #10
0
ファイル: test_packages.py プロジェクト: lalinsky/nosexunit
 def test_package(self):
     p = test_NoseXUnit.Package('foo').save(self.source)
     expected = {'foo': p.path(), }
     self.assertEquals(expected, ntools.packages(self.source, search=False, exclude=[]))
コード例 #11
0
ファイル: test_packages.py プロジェクト: lalinsky/nosexunit
 def test_exclude(self):
     f = test_NoseXUnit.Folder('CVS')
     m = test_NoseXUnit.Module('foo')
     f.append(m)
     f.save(self.source)
     self.assertEquals({}, ntools.packages(self.source, search=True, exclude=['CVS', ]))
コード例 #12
0
ファイル: test_packages.py プロジェクト: lalinsky/nosexunit
 def test_no_search(self):
     f = test_NoseXUnit.Folder('folder')
     m = test_NoseXUnit.Module('foo')
     f.append(m)
     f.save(self.source)
     self.assertEquals({}, ntools.packages(self.source, search=False, exclude=[]))