@@ -705,27 +705,41 @@ def test_to_timestamp_microsecond(self, ts, expected, freq):
705
705
# --------------------------------------------------------------
706
706
# Rendering: __repr__, strftime, etc
707
707
708
- def test_repr (self ):
709
- p = Period ("Jan-2000" )
710
- assert "2000-01" in repr (p )
711
-
712
- p = Period ("2000-12-15" )
713
- assert "2000-12-15" in repr (p )
708
+ @pytest .mark .parametrize (
709
+ "str_ts,freq,str_res,str_freq" ,
710
+ (
711
+ ("Jan-2000" , None , "2000-01" , "M" ),
712
+ ("2000-12-15" , None , "2000-12-15" , "D" ),
713
+ (
714
+ "2000-12-15 13:45:26.123456789" ,
715
+ "N" ,
716
+ "2000-12-15 13:45:26.123456789" ,
717
+ "N" ,
718
+ ),
719
+ ("2000-12-15 13:45:26.123456789" , "U" , "2000-12-15 13:45:26.123456" , "U" ),
720
+ ("2000-12-15 13:45:26.123456" , None , "2000-12-15 13:45:26.123456" , "U" ),
721
+ ("2000-12-15 13:45:26.123456789" , "L" , "2000-12-15 13:45:26.123" , "L" ),
722
+ ("2000-12-15 13:45:26.123" , None , "2000-12-15 13:45:26.123" , "L" ),
723
+ ("2000-12-15 13:45:26" , "S" , "2000-12-15 13:45:26" , "S" ),
724
+ ("2000-12-15 13:45:26" , "T" , "2000-12-15 13:45" , "T" ),
725
+ ("2000-12-15 13:45:26" , "H" , "2000-12-15 13:00" , "H" ),
726
+ ("2000-12-15" , "Y" , "2000" , "A-DEC" ),
727
+ ("2000-12-15" , "Q" , "2000Q4" , "Q-DEC" ),
728
+ ("2000-12-15" , "M" , "2000-12" , "M" ),
729
+ ("2000-12-15" , "W" , "2000-12-11/2000-12-17" , "W-SUN" ),
730
+ ("2000-12-15" , "D" , "2000-12-15" , "D" ),
731
+ ("2000-12-15" , "B" , "2000-12-15" , "B" ),
732
+ ),
733
+ )
734
+ def test_repr (self , str_ts , freq , str_res , str_freq ):
735
+ p = Period (str_ts , freq = freq )
736
+ assert str (p ) == str_res
737
+ assert repr (p ) == f"Period('{ str_res } ', '{ str_freq } ')"
714
738
715
739
def test_repr_nat (self ):
716
740
p = Period ("nat" , freq = "M" )
717
741
assert repr (NaT ) in repr (p )
718
742
719
- def test_millisecond_repr (self ):
720
- p = Period ("2000-01-01 12:15:02.123" )
721
-
722
- assert repr (p ) == "Period('2000-01-01 12:15:02.123', 'L')"
723
-
724
- def test_microsecond_repr (self ):
725
- p = Period ("2000-01-01 12:15:02.123567" )
726
-
727
- assert repr (p ) == "Period('2000-01-01 12:15:02.123567', 'U')"
728
-
729
743
def test_strftime (self ):
730
744
# GH#3363
731
745
p = Period ("2000-1-1 12:34:12" , freq = "S" )
0 commit comments