@@ -961,109 +961,6 @@ It moves your instance to the middle date between itself and the provided Pendul
961961 # first_of(), last_of(), nth_of()
962962
963963
964- Testing
965- =======
966-
967- The testing methods allow you to set a ``Pendulum `` instance (real or mock) to be returned
968- when a "now" instance is created.
969- The provided instance will be returned specifically under the following conditions:
970-
971- * A call to the ``now() `` method, ex. ``pendulum.now() ``.
972- * When the string "now" is passed to the ``parse() ``, ex. ``pendulum.parse('now') ``
973-
974- .. code-block :: python
975-
976- import pendulum
977-
978- # Create testing datetime
979- known = pendulum.create(2001 , 5 , 21 , 12 )
980-
981- # Set the mock
982- pendulum.set_test_now(known)
983-
984- print (pendulum.now())
985- ' 2001-05-21T12:00:00+00:00'
986-
987- print (pendulum.parse(' now' ))
988- ' 2001-05-21T12:00:00+00:00'
989-
990- # Clear the mock
991- pendulum.set_test_now()
992-
993- print (pendulum.now())
994- ' 2016-07-10T22:10:33.954851-05:00'
995-
996- Related methods will also returned values mocked according to the *now * instance.
997-
998- .. code-block :: python
999-
1000- print (pendulum.today())
1001- ' 2001-05-21T00:00:00+00:00'
1002-
1003- print (pendulum.tomorrow())
1004- ' 2001-05-22T00:00:00+00:00'
1005-
1006- print (pendulum.yesterday())
1007- ' 2001-05-20T00:00:00+00:00'
1008-
1009- If you don't want to manually clear the mock (or you are afraid of forgetting),
1010- you can use the provided ``test() `` contextmanager.
1011-
1012- .. code-block :: python
1013-
1014- import pendulum
1015-
1016- known = pendulum.create(2001 , 5 , 21 , 12 )
1017-
1018- with pendulum.test(known):
1019- print (pendulum.now())
1020- ' 2001-05-21T12:00:00+00:00'
1021-
1022- print (pendulum.now())
1023- ' 2016-07-10T22:10:33.954851-05:00'
1024-
1025-
1026- Constants
1027- =========
1028-
1029- The following constants are defined in the Pendulum class and at module
1030- level.
1031-
1032- .. code-block :: python
1033-
1034- SUNDAY
1035- 0
1036- MONDAY
1037- 1
1038- TUESDAY
1039- 2
1040- WEDNESDAY
1041- 3
1042- THURSDAY
1043- 4
1044- FRIDAY
1045- 5
1046- SATURDAY
1047- 6
1048-
1049- YEARS_PER_CENTURY
1050- 100
1051- YEARS_PER_DECADE
1052- 10
1053- MONTHS_PER_YEAR
1054- 12
1055- WEEKS_PER_YEAR
1056- 52
1057- DAYS_PER_WEEK
1058- 7
1059- HOURS_PER_DAY
1060- 24
1061- MINUTES_PER_HOUR
1062- 60
1063- SECONDS_PER_MINUTE
1064- 60
1065-
1066-
1067964 Timezones
1068965=========
1069966
@@ -1192,6 +1089,68 @@ when adding and subtracting time around transition times.
11921089 ' 2013-03-31T03:00:00+02:00'
11931090
11941091
1092+ Testing
1093+ =======
1094+
1095+ The testing methods allow you to set a ``Pendulum `` instance (real or mock) to be returned
1096+ when a "now" instance is created.
1097+ The provided instance will be returned specifically under the following conditions:
1098+
1099+ * A call to the ``now() `` method, ex. ``pendulum.now() ``.
1100+ * When the string "now" is passed to the ``parse() ``, ex. ``pendulum.parse('now') ``
1101+
1102+ .. code-block :: python
1103+
1104+ import pendulum
1105+
1106+ # Create testing datetime
1107+ known = pendulum.create(2001 , 5 , 21 , 12 )
1108+
1109+ # Set the mock
1110+ pendulum.set_test_now(known)
1111+
1112+ print (pendulum.now())
1113+ ' 2001-05-21T12:00:00+00:00'
1114+
1115+ print (pendulum.parse(' now' ))
1116+ ' 2001-05-21T12:00:00+00:00'
1117+
1118+ # Clear the mock
1119+ pendulum.set_test_now()
1120+
1121+ print (pendulum.now())
1122+ ' 2016-07-10T22:10:33.954851-05:00'
1123+
1124+ Related methods will also returned values mocked according to the *now * instance.
1125+
1126+ .. code-block :: python
1127+
1128+ print (pendulum.today())
1129+ ' 2001-05-21T00:00:00+00:00'
1130+
1131+ print (pendulum.tomorrow())
1132+ ' 2001-05-22T00:00:00+00:00'
1133+
1134+ print (pendulum.yesterday())
1135+ ' 2001-05-20T00:00:00+00:00'
1136+
1137+ If you don't want to manually clear the mock (or you are afraid of forgetting),
1138+ you can use the provided ``test() `` contextmanager.
1139+
1140+ .. code-block :: python
1141+
1142+ import pendulum
1143+
1144+ known = pendulum.create(2001 , 5 , 21 , 12 )
1145+
1146+ with pendulum.test(known):
1147+ print (pendulum.now())
1148+ ' 2001-05-21T12:00:00+00:00'
1149+
1150+ print (pendulum.now())
1151+ ' 2016-07-10T22:10:33.954851-05:00'
1152+
1153+
11951154 Interval
11961155========
11971156
0 commit comments