Example #1
0
    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))
Example #2
0
    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));
Example #3
0
    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));
Example #4
0
    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));
Example #5
0
    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))
Example #6
0
    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))
Example #7
0
    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');
Example #8
0
    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))
Example #9
0
    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')
Example #10
0
    def testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF(self):

        value = '686e444';

        self.assertEqual(value, Inline.parse(Inline.dump(value)));
Example #11
0
    def testDumpNumericValueWithLocale(self):

        self.assertEqual('1.2', Inline.dump(1.2));
Example #12
0
    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));
Example #13
0
    def testParseScalarWithCorrectlyQuotedStringShouldReturnString(self):

        value = "'don''t do somthin'' like that'";
        expect = "don't do somthin' like that";

        self.assertEqual(expect, Inline.parseScalar(value));
Example #14
0
    def testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF(
            self):

        value = '686e444'

        self.assertEqual(value, Inline.parse(Inline.dump(value)))
Example #15
0
    def testDumpNumericValueWithLocale(self):

        self.assertEqual('1.2', Inline.dump(1.2))
Example #16
0
    def testParseScalarWithCorrectlyQuotedStringShouldReturnString(self):

        value = "'don''t do somthin'' like that'"
        expect = "don't do somthin' like that"

        self.assertEqual(expect, Inline.parseScalar(value))