8000 tests/extmod: Add a simple test for machine.RTC. · micropython/micropython@6d98280 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d98280

Browse files
committed
tests/extmod: Add a simple test for machine.RTC.
Tests at least that the datetime can be set and get correctly. Signed-off-by: Damien George <damien@micropython.org>
1 parent 47741e2 commit 6d98280

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/extmod/machine_rtc.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Test basic behaviour of machine.RTC.
2+
3+
try:
4+
from machine import RTC
5+
except ImportError:
6+
print("SKIP")
7+
raise SystemExit
8+
9+
rtc = machine.RTC()
10+
11+
# Save datetime.
12+
orig_datetime = rtc.datetime()
13+
14+
# Set datetime to a known value.
15+
rtc.datetime((2020, 1, 1, 0, 0, 0, 0, 0))
16+
17+
# Check that getting and setting the datetime give expected values.
18+
for i in range(4):
19+
now = rtc.datetime()
20+
print(now[0], now[1], now[2], now[4], now[5])
21+
rtc.datetime(now)
22+
23+
# Restore datetime.
24+
rtc.datetime(orig_datetime)

tests/extmod/machine_rtc.py.exp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2020 1 1 0 0
2+
2020 1 1 0 0
3+
2020 1 1 0 0
4+
2020 1 1 0 0

0 commit comments

Comments
 (0)
0