[lang-ref] ( get_now ) ( python )

def test_get_now():
    # datetime.datetime.now()
    p = subprocess.Popen(['date', r'+%Y/%m/%d %H:%M:%S'], stdout=subprocess.PIPE, text=True, encoding='utf-8')
    stdout, _ = p.communicate()
    expected = datetime.datetime.strptime(stdout.rstrip(), r'%Y/%m/%d %H:%M:%S')

    actual = datetime.datetime.now()

    assert abs((actual - expected).total_seconds()) <= 1