コード例 #1
0
ファイル: test_datetime.py プロジェクト: nwebs/rdflib
    def test_microseconds(self):
        dt1 = datetime(2009, 6, 15, 23, 37, 6, 522630)
        l = Literal(dt1)

        # datetime with microseconds should be cast as a literal with using
        # XML Schema dateTime as the literal datatype
        self.assertEquals(l.title(), '2009-06-15T23:37:06.522630')
        self.assertEquals(l.datatype, XSD.dateTime)

        dt2 = l.toPython()
        self.assertEqual(dt2, dt1)
コード例 #2
0
    def test_microseconds(self):
        import platform

        if platform.system() == "Java" or (platform.system() != "Java" and sys.version_info[:2] == (2, 5)):
            from nose import SkipTest

            raise SkipTest("datetime microseconds unsupported in Python2.5 and Jython")
        dt1 = datetime(2009, 6, 15, 23, 37, 6, 522630)
        l = Literal(dt1)

        # datetime with microseconds should be cast as a literal with using
        # XML Schema dateTime as the literal datatype
        self.assertEquals(l.title(), "2009-06-15T23:37:06.522630")
        self.assertEquals(l.datatype, XSD.dateTime)

        dt2 = l.toPython()
        self.assertEqual(dt2, dt1)
コード例 #3
0
    def test_microseconds(self):
        import platform
        if platform.system() == 'Java' or (platform.system() != 'Java'
                                           and sys.version_info[:2] == (2, 5)):
            from nose import SkipTest
            raise SkipTest(
                'datetime microseconds unsupported in Python2.5 and Jython')
        dt1 = datetime(2009, 6, 15, 23, 37, 6, 522630)
        l = Literal(dt1)

        # datetime with microseconds should be cast as a literal with using
        # XML Schema dateTime as the literal datatype
        self.assertEquals(l.title(), '2009-06-15T23:37:06.522630')
        self.assertEquals(l.datatype, XSD.dateTime)

        dt2 = l.toPython()
        self.assertEqual(dt2, dt1)
コード例 #4
0
ファイル: test_datetime.py プロジェクト: alcides/rdflib
    def test_microseconds(self):
        dt1 = datetime(2009, 6, 15, 23, 37, 6, 522630)
        l = Literal(dt1)

        # datetime with microseconds should be cast as a literal with using
        # XML Schema dateTime as the literal datatype
        self.assertEquals(l.title(), '2009-06-15T23:37:06.522630')
        self.assertEquals(l.datatype, XSD.dateTime)

        # 2.6.0 added the %f format to datetime.strftime, so we should have
        # a lossless conversion back to the datetime
        # http://bugs.python.org/issue1982
        if sys.version_info >= (2,6,0):
            dt2 = l.toPython()
            self.assertEqual(dt2, dt1)

        # otherwise, we just get back the same literal again
        else:
            dt2 = l.toPython()
            l2 = Literal('2009-06-15T23:37:06.522630', datatype=XSD.dateTime)
            self.assertTrue(l2, l.toPython())
コード例 #5
0
    def test_microseconds(self):
        dt1 = datetime(2009, 6, 15, 23, 37, 6, 522630)
        l = Literal(dt1)

        # datetime with microseconds should be cast as a literal with using
        # XML Schema dateTime as the literal datatype
        self.assertEquals(l.title(), '2009-06-15T23:37:06.522630')
        self.assertEquals(l.datatype, XSD.dateTime)

        # 2.6.0 added the %f format to datetime.strftime, so we should have
        # a lossless conversion back to the datetime
        # http://bugs.python.org/issue1982
        if sys.version_info >= (2,6,0):
            dt2 = l.toPython()
            self.assertEqual(dt2, dt1)

        # otherwise, we just get back the same literal again
        else:
            dt2 = l.toPython()
            l2 = Literal('2009-06-15T23:37:06.522630', datatype=XSD.dateTime)
            self.assertTrue(l2, l.toPython())