def testParseInvalidMappingShouldThrowException(self): """@expectedException: Symfony\Component\Yaml\Exception\ParseException """ try: Inline.parse('[foo] bar') self.fail() except Exception as e: self.assertTrue(isinstance(e, ParseException))
def testParseInvalidMappingShouldThrowException(self): """@expectedException: Symfony\Component\Yaml\Exception\ParseException """ try: Inline.parse('[foo] bar'); self.fail() except Exception as e: self.assertTrue(isinstance(e, ParseException));
def testParseInvalidMappingKeyShouldThrowException(self): """@expectedException: Symfony\Component\Yaml\Exception\ParseException """ try: value = '{ "foo " bar": "bar" }'; Inline.parse(value); self.fail() except Exception as e: self.assertTrue(isinstance(e, ParseException));
def testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException(self): """@expectedException: Symfony\Component\Yaml\Exception\ParseException """ try: value = '"don"t do somthin" like that"'; Inline.parse(value); self.fail() except Exception as e: self.assertTrue(isinstance(e, ParseException));
def testParseInvalidMappingKeyShouldThrowException(self): """@expectedException: Symfony\Component\Yaml\Exception\ParseException """ try: value = '{ "foo " bar": "bar" }' Inline.parse(value) self.fail() except Exception as e: self.assertTrue(isinstance(e, ParseException))
def testParseScalarWithIncorrectlyQuotedStringShouldThrowException(self): """@expectedException: Symfony\Component\Yaml\Exception\ParseException """ try: value = "'don't do somthin' like that'" Inline.parse(value) self.fail() except Exception as e: self.assertTrue(isinstance(e, ParseException))
def testDump(self): testsForDump = self._getTestsForDump(); for yaml, value in testsForDump.items(): self.assertEqual(yaml, Inline.dump(value), '::dump() converts a PHP structure to an inline YAML ({0})'.format(yaml)); for yaml, value in self._getTestsForParse().items(): self.assertEqual(value, Inline.parse(Inline.dump(value)), 'check consistency'); for yaml, value in testsForDump.items(): self.assertEqual(value, Inline.parse(Inline.dump(value)), 'check consistency');
def testParse(self): for yaml, value in self._getTestsForParse().items(): self.assertEqual( value, Inline.parse(yaml), '::parse() converts an inline YAML to a PHP structure ({0})'. format(yaml))
def testDump(self): testsForDump = self._getTestsForDump() for yaml, value in testsForDump.items(): self.assertEqual( yaml, Inline.dump(value), '::dump() converts a PHP structure to an inline YAML ({0})'. format(yaml)) for yaml, value in self._getTestsForParse().items(): self.assertEqual(value, Inline.parse(Inline.dump(value)), 'check consistency') for yaml, value in testsForDump.items(): self.assertEqual(value, Inline.parse(Inline.dump(value)), 'check consistency')
def testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF(self): value = '686e444'; self.assertEqual(value, Inline.parse(Inline.dump(value)));
def testParse(self): for yaml, value in self._getTestsForParse().items(): self.assertEqual(value, Inline.parse(yaml), '::parse() converts an inline YAML to a PHP structure ({0})'.format(yaml));
def testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF( self): value = '686e444' self.assertEqual(value, Inline.parse(Inline.dump(value)))