コード例 #1
0
 def setUp(self):
     """
     Define the config file and the Config object.
     """
     problems_dir = os.path.join(os.path.dirname(__file__), os.pardir,
                                 os.pardir, 'mock_problems')
     self.config_file = os.path.join(problems_dir,
                                     'be_box_nosource_steady.ini')
     self.conf = read_config.Config(self.config_file)
コード例 #2
0
    def test_not_blank_config(self):
        """
        Test a variety of values for a non empty config file.
        """
        with open(self.conf_file.name, 'w') as f:
            f.write('[SOLVER]\n'
                    'file_path: correct_file_path\n'
                    'method: new_method\n'
                    '[PARAMETERS]\n'
                    'part1: 8\n')
        c = read_config.Config(self.conf_file.name)

        self.assertEqual(c.conf_parser['SOLVER']['file_path'],
                         'correct_file_path')
        self.assertEqual(c.conf_parser['SOLVER']['method'], 'new_method')
        self.assertEqual(c.conf_parser['PARAMETERS']['part1'], '8')
コード例 #3
0
    def test_blank_config(self):
        """
        Test some required values for a blank config file.
        """
        c = read_config.Config(self.conf_file.name)

        self.assertIn('SOLVER', c.conf_parser)
        self.assertIn('file_path', c.conf_parser['SOLVER'])
        self.assertIn('method', c.conf_parser['SOLVER'])
        self.assertIn('MESH', c.conf_parser)
        self.assertIn('type', c.conf_parser['MESH'])
        self.assertIn('params', c.conf_parser['MESH'])
        self.assertIn('PARAMETERS', c.conf_parser)
        self.assertIn('SOURCES', c.conf_parser)
        self.assertIn('BOUNDARIES', c.conf_parser)
        self.assertIn('TIME', c.conf_parser)
        self.assertIn('INITIALVALUE', c.conf_parser)
コード例 #4
0
 def test_non_existent_config(self):
     """
     Test that exception is raised for non-existant config file.
     """
     with self.assertRaises(ValueError):
         _ = read_config.Config('fake_name.not_a_file')