Example #1
0
class TestCaseWithIni(Pep8CompliantTestCase):
    """
    Use this for unit tests that need access to settings specified in an
    .ini file.
    
    :ivar ini: The ini file parser. This will only be set up if the 
        `ini_file_path` and `ini_section_name` class variables were set up 
        sensibly.  
    """
    # : The name of the package where the tests reside. May be overridden in
    # : derived classes.
    package_name = 'everest'
    # : The path to the application initialization (ini) file name. Override
    # : as needed in derived classes.
    ini_file_path = None
    # : The section name in the ini file to look for settings. Override as
    # : needed in derived classes.
    ini_section_name = None

    def set_up(self):
        self.ini = EverestIni(self.ini_file_path)

    def tear_down(self):
        super(TestCaseWithIni, self).tear_down()
        try:
            del self.ini
        except AttributeError:
            pass

    def _get_app_url(self):
        section = 'server:main'
        if self.ini.has_setting(section, 'host'):
            host = self.ini.get_setting(section, 'host')
        else:
            host = '0.0.0.0'
        if self.ini.has_setting(section, 'port'):
            port = int(self.ini.get_setting(section, 'port'))
        else:
            port = 6543
        return 'http://%s:%d' % (host, port)
Example #2
0
class TestCaseWithIni(Pep8CompliantTestCase):
    """
    Use this for unit tests that need access to settings specified in an
    .ini file.
    
    :ivar ini: The ini file parser. This will only be set up if the 
        `ini_file_path` and `ini_section_name` class variables were set up 
        sensibly.  
    """
    # : The name of the package where the tests reside. May be overridden in
    # : derived classes.
    package_name = 'everest'
    # : The path to the application initialization (ini) file name. Override
    # : as needed in derived classes.
    ini_file_path = None
    # : The section name in the ini file to look for settings. Override as
    # : needed in derived classes.
    ini_section_name = None

    def set_up(self):
        self.ini = EverestIni(self.ini_file_path)

    def tear_down(self):
        super(TestCaseWithIni, self).tear_down()
        try:
            del self.ini
        except AttributeError:
            pass

    def _get_app_url(self):
        section = 'server:main'
        if self.ini.has_setting(section, 'host'):
            host = self.ini.get_setting(section, 'host')
        else:
            host = '0.0.0.0'
        if self.ini.has_setting(section, 'port'):
            port = int(self.ini.get_setting(section, 'port'))
        else:
            port = 6543
        return 'http://%s:%d' % (host, port)
Example #3
0
 def set_up(self):
     self.ini = EverestIni(self.ini_file_path)
Example #4
0
 def set_up(self):
     self.ini = EverestIni(self.ini_file_path)