Commits

Anonymous committed 195bd51

excluded plugins set is put in config

Comments (0)

Files changed (2)

 ##################################################################
 [project attributes]
 proj.directory-list = [{'dirloc': loc('.'),
-                        'excludes': [u'unittest2.egg-info',
+                        'excludes': [u'dist',
+                                     u'temp',
+                                     u'htmlcov',
                                      u'unittest2/__pycache__',
-                                     u'dist',
                                      u'build',
-                                     u'temp'],
+                                     u'unittest2.egg-info'],
                         'filter': '*',
                         'include_hidden': False,
                         'recursive': True,
 from ConfigParser import SafeConfigParser
 from ConfigParser import Error as ConfigParserError
 
-CFG_NAME = 'unittest.cfg'
+__all__ = (
+    'loadConfig',
+    'getConfig',
+)
+
+USER_DIR = '~'
+CFG_NAMES = (
+    'unittest.cfg',
+    '.unittest.cfg',
+)
 
 DEFAULT = object()
 RETURN_DEFAULT = object()
 
 _config = None
 
-__all__ = (
-    'loadConfig',
-    'getConfig',
-)
-
 def getConfig(section=None):
     # warning! mutable
     if section is None:
     
     configs = []
     if not noUserConfig:
-        cfgPath = os.path.join(os.path.expanduser('~'), CFG_NAME)
+        for CFG_NAME in CFG_NAMES:
+            cfgPath = os.path.join(os.path.expanduser(USER_DIR), CFG_NAME)
+            if os.path.isfile(cfgPath):
+                break
         userParser, userPlugins, userExcludedPlugins = loadPluginsConfigFile(cfgPath)
         configs.append((userPlugins, userParser, userExcludedPlugins))
     
     if configLocations is None:
-        cfgPath = os.path.join(os.getcwd(), CFG_NAME)
+        for CFG_NAME in CFG_NAMES:
+            cfgPath = os.path.join(os.getcwd(), CFG_NAME)
+            if os.path.isfile(cfgPath):
+                break
         localParser, localPlugins, localExcludedPlugins = loadPluginsConfigFile(cfgPath)
         configs.append((localPlugins, localParser, localExcludedPlugins))
         configLocations = []
     for entry in configLocations:
         path = entry
         if not os.path.isfile(path):
-            path = os.path.join(path, CFG_NAME)
-            if not os.path.isfile(path):
+            for CFG_NAME in CFG_NAMES:
+                path = os.path.join(path, CFG_NAME)
+                if os.path.isfile(path):
+                    break
+            else:
                 # exception type?
                 raise Exception('Config file location %r could not be found'
                                 % entry)
     parsers = [parser for _, parser, __ in configs]
     excludedPlugins = set(sum([excluded for _, __, excluded in configs], []))
     _config = combineConfigs(parsers)
-    return plugins - excludedPlugins
+    finalPlugins = plugins - excludedPlugins
+    unittestSection = _config.get('unittest', Section('unittest'))
+    unittestSection['plugins'] = finalPlugins
+    unittestSection['excluded-plugins'] = excludedPlugins
+    return finalPlugins
 
 
 class Section(dict):