Exemplo n.º 1
0
    def test_datetimeWithTimezoneIsInvalid(self):
        import datetime as dt
        
        ZERO = dt.timedelta(0)
        HOUR = dt.timedelta(hours=1)

        # A UTC class.

        class UTC(dt.tzinfo):
            """UTC"""

            def utcoffset(self, dt):
                return ZERO

            def tzname(self, dt):
                return "UTC"

            def dst(self, dt):
                return ZERO

        utc = UTC()

        invalid = dt.datetime(year=2011, month=3, day=19, hour=1, minute=24, second=0, tzinfo=utc)
        try:
            updater.validate_dt_value(invalid)
        except ValueError, e:
            pass
Exemplo n.º 2
0
    def test_datetimeWithTimezoneIsInvalid(self):
        import datetime as dt

        ZERO = dt.timedelta(0)
        HOUR = dt.timedelta(hours=1)

        # A UTC class.

        class UTC(dt.tzinfo):
            """UTC"""
            def utcoffset(self, dt):
                return ZERO

            def tzname(self, dt):
                return "UTC"

            def dst(self, dt):
                return ZERO

        utc = UTC()

        invalid = dt.datetime(year=2011,
                              month=3,
                              day=19,
                              hour=1,
                              minute=24,
                              second=0,
                              tzinfo=utc)
        try:
            updater.validate_dt_value(invalid)
        except ValueError, e:
            pass
Exemplo n.º 3
0
 def test_validDateAsExpected(self):
     import datetime as dt
     
     valid = dt.datetime(year=2011, month=3, day=19, hour=1, minute=24, second=0)
     try:
         updater.validate_dt_value(valid)
     except ValueError, e:
         self.fail('Datetime %s should not raise ValueError: %s' % (valid, e))
Exemplo n.º 4
0
 def test_datetimeWithMicrosecondIsInvalid(self):
     import datetime as dt
     
     invalid = dt.datetime(year=2011, month=3, day=19, hour=1, minute=24, second=0, microsecond=1)
     try:
         updater.validate_dt_value(invalid)
     except ValueError, e:
         pass
Exemplo n.º 5
0
    def test_validDateAsExpected(self):
        import datetime as dt

        valid = dt.datetime(year=2011,
                            month=3,
                            day=19,
                            hour=1,
                            minute=24,
                            second=0)
        try:
            updater.validate_dt_value(valid)
        except ValueError, e:
            self.fail('Datetime %s should not raise ValueError: %s' %
                      (valid, e))
Exemplo n.º 6
0
    def test_datetimeWithMicrosecondIsInvalid(self):
        import datetime as dt

        invalid = dt.datetime(year=2011,
                              month=3,
                              day=19,
                              hour=1,
                              minute=24,
                              second=0,
                              microsecond=1)
        try:
            updater.validate_dt_value(invalid)
        except ValueError, e:
            pass