66import pytest
77from pyodata .v2 .model import Schema , Typ , StructTypeProperty , Types , EntityType , EdmStructTypeSerializer , \
88 Association , AssociationSet , EndRole , AssociationSetEndRole , TypeInfo , MetadataBuilder , ParserError , PolicyWarning , \
9- PolicyIgnore , Config , PolicyFatal , NullType , NullAssociation
9+ PolicyIgnore , Config , PolicyFatal , NullType , NullAssociation , current_timezone
1010from pyodata .exceptions import PyODataException , PyODataModelError , PyODataParserError
1111from tests .conftest import assert_logging_policy
1212
@@ -458,7 +458,7 @@ def test_traits_datetime():
458458
459459 # 1. direction Python -> OData
460460
461- testdate = datetime (2005 , 1 , 28 , 18 , 30 , 44 , 123456 , tzinfo = timezone . utc )
461+ testdate = datetime (2005 , 1 , 28 , 18 , 30 , 44 , 123456 , tzinfo = current_timezone () )
462462 assert typ .traits .to_literal (testdate ) == "datetime'2005-01-28T18:30:44.123456'"
463463
464464 # without miliseconds part
@@ -481,19 +481,22 @@ def test_traits_datetime():
481481 assert testdate .minute == 33
482482 assert testdate .second == 6
483483 assert testdate .microsecond == 654321
484+ assert testdate .tzinfo == current_timezone ()
484485
485486 # parsing without miliseconds
486487 testdate = typ .traits .from_literal ("datetime'1976-11-23T03:33:06'" )
487488 assert testdate .year == 1976
488489 assert testdate .second == 6
489490 assert testdate .microsecond == 0
491+ assert testdate .tzinfo == current_timezone ()
490492
491493 # parsing without seconds and miliseconds
492494 testdate = typ .traits .from_literal ("datetime'1976-11-23T03:33'" )
493495 assert testdate .year == 1976
494496 assert testdate .minute == 33
495497 assert testdate .second == 0
496498 assert testdate .microsecond == 0
499+ assert testdate .tzinfo == current_timezone ()
497500
498501 # parsing invalid value
499502 with pytest .raises (PyODataModelError ) as e_info :
@@ -515,19 +518,22 @@ def test_traits_datetime():
515518 assert testdate .minute == 33
516519 assert testdate .second == 6
517520 assert testdate .microsecond == 10000
521+ assert testdate .tzinfo == current_timezone ()
518522
519523 # parsing without miliseconds
520524 testdate = typ .traits .from_json ("/Date(217567986000)/" )
521525 assert testdate .year == 1976
522526 assert testdate .second == 6
523527 assert testdate .microsecond == 0
528+ assert testdate .tzinfo == current_timezone ()
524529
525530 # parsing without seconds and miliseconds
526531 testdate = typ .traits .from_json ("/Date(217567980000)/" )
527532 assert testdate .year == 1976
528533 assert testdate .minute == 33
529534 assert testdate .second == 0
530535 assert testdate .microsecond == 0
536+ assert testdate .tzinfo == current_timezone ()
531537
532538 # parsing the lowest value
533539 with pytest .raises (OverflowError ):
@@ -541,6 +547,7 @@ def test_traits_datetime():
541547 assert testdate .minute == 0
542548 assert testdate .second == 0
543549 assert testdate .microsecond == 0
550+ assert testdate .tzinfo == current_timezone ()
544551
545552 # parsing the highest value
546553 with pytest .raises (OverflowError ):
@@ -554,6 +561,7 @@ def test_traits_datetime():
554561 assert testdate .minute == 59
555562 assert testdate .second == 59
556563 assert testdate .microsecond == 999000
564+ assert testdate .tzinfo == current_timezone ()
557565
558566 # parsing invalid value
559567 with pytest .raises (PyODataModelError ) as e_info :
0 commit comments