add test script for manipulating datetime
This commit is contained in:
parent
1cad8d1127
commit
ac92ef4951
31
test/run_time_machine.py
Executable file
31
test/run_time_machine.py
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
|
import time_machine
|
||||||
|
|
||||||
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
|
from ffplayout.output import desktop
|
||||||
|
|
||||||
|
_tz = ZoneInfo("Europe/Berlin")
|
||||||
|
source_time = [2021, 2, 8, 23, 59, 50]
|
||||||
|
|
||||||
|
|
||||||
|
@time_machine.travel(datetime.datetime(*source_time, tzinfo=_tz))
|
||||||
|
def run_in_time_machine():
|
||||||
|
try:
|
||||||
|
assert datetime.datetime.now() == datetime.datetime(*source_time)
|
||||||
|
except AssertionError:
|
||||||
|
print('Assertion not possible')
|
||||||
|
exit()
|
||||||
|
|
||||||
|
desktop.output()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run_in_time_machine()
|
Loading…
x
Reference in New Issue
Block a user