Back to index

python3.2  3.2.2
Public Member Functions
test.test_cfgparser.CoverageOneHundredTestCase Class Reference

List of all members.

Public Member Functions

def test_duplicate_option_error
def test_interpolation_depth_error
def test_parsing_error
def test_interpolation_validation
def test_readfp_deprecation
def test_safeconfigparser_deprecation
def test_sectionproxy_repr

Detailed Description

Covers edge cases in the codebase.

Definition at line 1392 of file test_cfgparser.py.


Member Function Documentation

Definition at line 1395 of file test_cfgparser.py.

01395 
01396     def test_duplicate_option_error(self):
01397         error = configparser.DuplicateOptionError('section', 'option')
01398         self.assertEqual(error.section, 'section')
01399         self.assertEqual(error.option, 'option')
01400         self.assertEqual(error.source, None)
01401         self.assertEqual(error.lineno, None)
01402         self.assertEqual(error.args, ('section', 'option', None, None))
01403         self.assertEqual(str(error), "Option 'option' in section 'section' "
01404                                      "already exists")

Here is the call graph for this function:

Definition at line 1405 of file test_cfgparser.py.

01405 
01406     def test_interpolation_depth_error(self):
01407         error = configparser.InterpolationDepthError('option', 'section',
01408                                                      'rawval')
01409         self.assertEqual(error.args, ('option', 'section', 'rawval'))
01410         self.assertEqual(error.option, 'option')
01411         self.assertEqual(error.section, 'section')

Here is the call graph for this function:

Definition at line 1431 of file test_cfgparser.py.

01431 
01432     def test_interpolation_validation(self):
01433         parser = configparser.ConfigParser()
01434         parser.read_string("""
01435             [section]
01436             invalid_percent = %
01437             invalid_reference = %(()
01438             invalid_variable = %(does_not_exist)s
01439         """)
01440         with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
01441             parser['section']['invalid_percent']
01442         self.assertEqual(str(cm.exception), "'%' must be followed by '%' or "
01443                                             "'(', found: '%'")
01444         with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
01445             parser['section']['invalid_reference']
01446         self.assertEqual(str(cm.exception), "bad interpolation variable "
01447                                             "reference '%(()'")

Here is the call graph for this function:

Definition at line 1412 of file test_cfgparser.py.

01412 
01413     def test_parsing_error(self):
01414         with self.assertRaises(ValueError) as cm:
01415             configparser.ParsingError()
01416         self.assertEqual(str(cm.exception), "Required argument `source' not "
01417                                             "given.")
01418         with self.assertRaises(ValueError) as cm:
01419             configparser.ParsingError(source='source', filename='filename')
01420         self.assertEqual(str(cm.exception), "Cannot specify both `filename' "
01421                                             "and `source'. Use `source'.")
01422         error = configparser.ParsingError(filename='source')
01423         self.assertEqual(error.source, 'source')
01424         with warnings.catch_warnings(record=True) as w:
01425             warnings.simplefilter("always", DeprecationWarning)
01426             self.assertEqual(error.filename, 'source')
01427             error.filename = 'filename'
01428             self.assertEqual(error.source, 'filename')
01429         for warning in w:
01430             self.assertTrue(warning.category is DeprecationWarning)

Here is the call graph for this function:

Definition at line 1448 of file test_cfgparser.py.

01448 
01449     def test_readfp_deprecation(self):
01450         sio = io.StringIO("""
01451         [section]
01452         option = value
01453         """)
01454         parser = configparser.ConfigParser()
01455         with warnings.catch_warnings(record=True) as w:
01456             warnings.simplefilter("always", DeprecationWarning)
01457             parser.readfp(sio, filename='StringIO')
01458         for warning in w:
01459             self.assertTrue(warning.category is DeprecationWarning)
01460         self.assertEqual(len(parser), 2)
01461         self.assertEqual(parser['section']['option'], 'value')

Here is the call graph for this function:

Definition at line 1462 of file test_cfgparser.py.

01462 
01463     def test_safeconfigparser_deprecation(self):
01464         with warnings.catch_warnings(record=True) as w:
01465             warnings.simplefilter("always", DeprecationWarning)
01466             parser = configparser.SafeConfigParser()
01467         for warning in w:
01468             self.assertTrue(warning.category is DeprecationWarning)

Here is the call graph for this function:

Definition at line 1469 of file test_cfgparser.py.

01469 
01470     def test_sectionproxy_repr(self):
01471         parser = configparser.ConfigParser()
01472         parser.read_string("""
01473             [section]
01474             key = value
01475         """)
01476         self.assertEqual(repr(parser['section']), '<Section: section>')

Here is the call graph for this function:


The documentation for this class was generated from the following file: