Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cf05d80c
TDengine
项目概览
taosdata
/
TDengine
8 个月 前同步成功
通知
1175
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cf05d80c
编写于
6月 18, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into hotfix/sangshuduo/TD-4765-random-fail-func
上级
4d9bad8c
94535428
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
16 deletion
+24
-16
src/connector/python/taos/cinterface.py
src/connector/python/taos/cinterface.py
+1
-1
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+23
-15
未找到文件。
src/connector/python/taos/cinterface.py
浏览文件 @
cf05d80c
...
...
@@ -15,7 +15,7 @@ def _convert_microsecond_to_datetime(micro):
def
_convert_nanosecond_to_datetime
(
nanosec
):
return
datetime
.
datetime
.
fromtimestamp
(
nanosec
/
1000000000.0
)
return
nanosec
def
_crow_timestamp_to_python
(
data
,
num_of_rows
,
nbytes
=
None
,
precision
=
FieldType
.
C_TIMESTAMP_UNKNOWN
):
...
...
tests/pytest/util/sql.py
浏览文件 @
cf05d80c
...
...
@@ -18,6 +18,7 @@ import datetime
import
inspect
import
psutil
import
shutil
import
pandas
as
pd
from
util.log
import
*
...
...
@@ -134,25 +135,32 @@ class TDSql:
return
self
.
cursor
.
istype
(
col
,
dataType
)
def
checkData
(
self
,
row
,
col
,
data
):
self
.
checkRowCol
(
row
,
col
)
if
self
.
queryResult
[
row
][
col
]
!=
data
:
if
self
.
cursor
.
istype
(
col
,
"TIMESTAMP"
)
and
self
.
queryResult
[
row
][
col
]
==
datetime
.
datetime
.
fromisoformat
(
data
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
self
.
checkRowCol
(
row
,
col
)
if
self
.
queryResult
[
row
][
col
]
!=
data
:
if
self
.
cursor
.
istype
(
col
,
"TIMESTAMP"
):
# suppose user want to check nanosecond timestamp if a longer data passed
if
(
len
(
data
)
>=
28
):
if
pd
.
to_datetime
(
self
.
queryResult
[
row
][
col
])
==
pd
.
to_datetime
(
data
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%d == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
else
:
if
self
.
queryResult
[
row
][
col
]
==
datetime
.
datetime
.
fromisoformat
(
data
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
return
if
str
(
self
.
queryResult
[
row
][
col
])
==
str
(
data
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
return
elif
isinstance
(
data
,
float
)
and
abs
(
self
.
queryResult
[
row
][
col
]
-
data
)
<=
0.000001
:
elif
isinstance
(
data
,
float
)
and
abs
(
self
.
queryResult
[
row
][
col
]
-
data
)
<=
0.000001
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%f == expect:%f"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
return
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
args
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
args
)
if
data
is
None
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
...
...
@@ -162,11 +170,11 @@ class TDSql:
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
datetime
.
date
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
float
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
else
:
else
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%d"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
...
...
@@ -200,7 +208,7 @@ class TDSql:
tdLog
.
exit
(
"%s(%d) failed: sql:%s, affectedRows:%d != expect:%d"
%
args
)
tdLog
.
info
(
"sql:%s, affectedRows:%d == expect:%d"
%
(
self
.
sql
,
self
.
affectedRows
,
expectAffectedRows
))
def
taosdStatus
(
self
,
state
):
tdLog
.
sleep
(
5
)
pstate
=
0
...
...
@@ -221,7 +229,7 @@ class TDSql:
continue
pstate
=
0
break
args
=
(
pstate
,
state
)
if
pstate
==
state
:
tdLog
.
info
(
"taosd state is %d == expect:%d"
%
args
)
...
...
@@ -236,11 +244,11 @@ class TDSql:
tdLog
.
exit
(
"dir: %s is empty, expect: not empty"
%
dir
)
else
:
tdLog
.
info
(
"dir: %s is empty, expect: empty"
%
dir
)
else
:
else
:
if
state
:
tdLog
.
info
(
"dir: %s is not empty, expect: not empty"
%
dir
)
else
:
tdLog
.
exit
(
"dir: %s is not empty, expect: empty"
%
dir
)
tdLog
.
exit
(
"dir: %s is not empty, expect: empty"
%
dir
)
else
:
tdLog
.
exit
(
"dir: %s doesn't exist"
%
dir
)
def
createDir
(
self
,
dir
):
...
...
@@ -250,5 +258,5 @@ class TDSql:
os
.
makedirs
(
dir
,
755
)
tdLog
.
info
(
"dir: %s is created"
%
dir
)
pass
tdSql
=
TDSql
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录