コード例 #1
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    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))
コード例 #2
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    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));
コード例 #3
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    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));
コード例 #4
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    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));
コード例 #5
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    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))
コード例 #6
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    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))
コード例 #7
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    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');
コード例 #8
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    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))
コード例 #9
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    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')
コード例 #10
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    def testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF(self):

        value = '686e444';

        self.assertEqual(value, Inline.parse(Inline.dump(value)));
コード例 #11
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    def testDumpNumericValueWithLocale(self):

        self.assertEqual('1.2', Inline.dump(1.2));
コード例 #12
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    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));
コード例 #13
0
ファイル: test_inline.py プロジェクト: visonforcoding/pymfony
    def testParseScalarWithCorrectlyQuotedStringShouldReturnString(self):

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

        self.assertEqual(expect, Inline.parseScalar(value));
コード例 #14
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    def testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF(
            self):

        value = '686e444'

        self.assertEqual(value, Inline.parse(Inline.dump(value)))
コード例 #15
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    def testDumpNumericValueWithLocale(self):

        self.assertEqual('1.2', Inline.dump(1.2))
コード例 #16
0
ファイル: test_inline.py プロジェクト: pombredanne/pymfony
    def testParseScalarWithCorrectlyQuotedStringShouldReturnString(self):

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

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