Changeset - e885a8efef34
[Not reviewed]
default
0 1 0
Mads Kiilerich - 7 years ago 2018-09-30 18:31:37
mads@kiilerich.com
tests: fix vcs Hg helper function get_config_value to not modify global state when using a custom config file

This leak was what made test_get_user_name and test_get_user_email pass when
test_get_config_value had been run first.
1 file changed with 2 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -593,24 +593,26 @@ class MercurialRepository(BaseRepository
 

	
 
        :param section: Section we want to retrieve value from
 
        :param name: Name of configuration we want to retrieve
 
        :param config_file: A path to file which should be used to retrieve
 
          configuration from (might also be a list of file paths)
 
        """
 
        if config_file is None:
 
            config_file = []
 
        elif isinstance(config_file, basestring):
 
            config_file = [config_file]
 

	
 
        config = self._repo.ui
 
        if config_file:
 
            config = ui.ui()
 
        for path in config_file:
 
            config.readconfig(path)
 
        return config.config(section, name)
 

	
 
    def get_user_name(self, config_file=None):
 
        """
 
        Returns user's name from global configuration file.
 

	
 
        :param config_file: A path to file which should be used to retrieve
 
          configuration from (might also be a list of file paths)
 
        """
 
        username = self.get_config_value('ui', 'username', config_file=config_file)
0 comments (0 inline, 0 general)