From 8395a20a20ff1ff68f46770812b4bccc08c8cfce Mon Sep 17 00:00:00 2001 From: Robert Manner Date: Fri, 14 Feb 2020 14:53:22 +0100 Subject: [PATCH] plugins/python/regress/testhelpers.c: replace fromisoformat fromisoformat is only supported from python >=3.7 --- plugins/python/regress/testhelpers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/python/regress/testhelpers.c b/plugins/python/regress/testhelpers.c index cca3d140d..7ce17b822 100644 --- a/plugins/python/regress/testhelpers.c +++ b/plugins/python/regress/testhelpers.c @@ -259,9 +259,10 @@ mock_python_datetime_now(const char *plugin_name, const char *date_str) char *cmd = NULL; asprintf(&cmd, "import %s\n" // the plugin has its own submodule "from datetime import datetime\n" // store the real datetime + "import time\n" "from unittest.mock import Mock\n" "%s.datetime = Mock()\n" // replace plugin's datetime - "%s.datetime.now = lambda: datetime.fromisoformat('%s')\n", + "%s.datetime.now = lambda: datetime.fromtimestamp(time.mktime(time.strptime('%s', '%%Y-%%m-%%dT%%H:%%M:%%S')))\n", plugin_name, plugin_name, plugin_name, date_str); VERIFY_PTR_NE(cmd, NULL); VERIFY_INT(PyRun_SimpleString(cmd), 0);