Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
78ee0784
Kaydet (Commit)
78ee0784
authored
Kas 16, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19601: Use specific asserts in sqlite3 tests.
üst
39989157
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
30 deletions
+20
-30
factory.py
Lib/sqlite3/test/factory.py
+19
-29
hooks.py
Lib/sqlite3/test/hooks.py
+1
-1
No files found.
Lib/sqlite3/test/factory.py
Dosyayı görüntüle @
78ee0784
...
@@ -47,9 +47,7 @@ class ConnectionFactoryTests(unittest.TestCase):
...
@@ -47,9 +47,7 @@ class ConnectionFactoryTests(unittest.TestCase):
self
.
con
.
close
()
self
.
con
.
close
()
def
CheckIsInstance
(
self
):
def
CheckIsInstance
(
self
):
self
.
assertTrue
(
isinstance
(
self
.
con
,
self
.
assertIsInstance
(
self
.
con
,
MyConnection
)
MyConnection
),
"connection is not instance of MyConnection"
)
class
CursorFactoryTests
(
unittest
.
TestCase
):
class
CursorFactoryTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -60,9 +58,7 @@ class CursorFactoryTests(unittest.TestCase):
...
@@ -60,9 +58,7 @@ class CursorFactoryTests(unittest.TestCase):
def
CheckIsInstance
(
self
):
def
CheckIsInstance
(
self
):
cur
=
self
.
con
.
cursor
(
factory
=
MyCursor
)
cur
=
self
.
con
.
cursor
(
factory
=
MyCursor
)
self
.
assertTrue
(
isinstance
(
cur
,
self
.
assertIsInstance
(
cur
,
MyCursor
)
MyCursor
),
"cursor is not instance of MyCursor"
)
class
RowFactoryTestsBackwardsCompat
(
unittest
.
TestCase
):
class
RowFactoryTestsBackwardsCompat
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -72,9 +68,7 @@ class RowFactoryTestsBackwardsCompat(unittest.TestCase):
...
@@ -72,9 +68,7 @@ class RowFactoryTestsBackwardsCompat(unittest.TestCase):
cur
=
self
.
con
.
cursor
(
factory
=
MyCursor
)
cur
=
self
.
con
.
cursor
(
factory
=
MyCursor
)
cur
.
execute
(
"select 4+5 as foo"
)
cur
.
execute
(
"select 4+5 as foo"
)
row
=
cur
.
fetchone
()
row
=
cur
.
fetchone
()
self
.
assertTrue
(
isinstance
(
row
,
self
.
assertIsInstance
(
row
,
dict
)
dict
),
"row is not instance of dict"
)
cur
.
close
()
cur
.
close
()
def
tearDown
(
self
):
def
tearDown
(
self
):
...
@@ -87,28 +81,24 @@ class RowFactoryTests(unittest.TestCase):
...
@@ -87,28 +81,24 @@ class RowFactoryTests(unittest.TestCase):
def
CheckCustomFactory
(
self
):
def
CheckCustomFactory
(
self
):
self
.
con
.
row_factory
=
lambda
cur
,
row
:
list
(
row
)
self
.
con
.
row_factory
=
lambda
cur
,
row
:
list
(
row
)
row
=
self
.
con
.
execute
(
"select 1, 2"
)
.
fetchone
()
row
=
self
.
con
.
execute
(
"select 1, 2"
)
.
fetchone
()
self
.
assertTrue
(
isinstance
(
row
,
self
.
assertIsInstance
(
row
,
list
)
list
),
"row is not instance of list"
)
def
CheckSqliteRowIndex
(
self
):
def
CheckSqliteRowIndex
(
self
):
self
.
con
.
row_factory
=
sqlite
.
Row
self
.
con
.
row_factory
=
sqlite
.
Row
row
=
self
.
con
.
execute
(
"select 1 as a, 2 as b"
)
.
fetchone
()
row
=
self
.
con
.
execute
(
"select 1 as a, 2 as b"
)
.
fetchone
()
self
.
assertTrue
(
isinstance
(
row
,
self
.
assertIsInstance
(
row
,
sqlite
.
Row
)
sqlite
.
Row
),
"row is not instance of sqlite.Row"
)
col1
,
col2
=
row
[
"a"
],
row
[
"b"
]
col1
,
col2
=
row
[
"a"
],
row
[
"b"
]
self
.
assert
True
(
col1
==
1
,
"by name: wrong result for column 'a'"
)
self
.
assert
Equal
(
col1
,
1
,
"by name: wrong result for column 'a'"
)
self
.
assert
True
(
col2
==
2
,
"by name: wrong result for column 'a'"
)
self
.
assert
Equal
(
col2
,
2
,
"by name: wrong result for column 'a'"
)
col1
,
col2
=
row
[
"A"
],
row
[
"B"
]
col1
,
col2
=
row
[
"A"
],
row
[
"B"
]
self
.
assert
True
(
col1
==
1
,
"by name: wrong result for column 'A'"
)
self
.
assert
Equal
(
col1
,
1
,
"by name: wrong result for column 'A'"
)
self
.
assert
True
(
col2
==
2
,
"by name: wrong result for column 'B'"
)
self
.
assert
Equal
(
col2
,
2
,
"by name: wrong result for column 'B'"
)
col1
,
col2
=
row
[
0
],
row
[
1
]
col1
,
col2
=
row
[
0
],
row
[
1
]
self
.
assert
True
(
col1
==
1
,
"by index: wrong result for column 0"
)
self
.
assert
Equal
(
col1
,
1
,
"by index: wrong result for column 0"
)
self
.
assert
True
(
col2
==
2
,
"by index: wrong result for column 1"
)
self
.
assert
Equal
(
col2
,
2
,
"by index: wrong result for column 1"
)
def
CheckSqliteRowIter
(
self
):
def
CheckSqliteRowIter
(
self
):
"""Checks if the row object is iterable"""
"""Checks if the row object is iterable"""
...
@@ -138,8 +128,8 @@ class RowFactoryTests(unittest.TestCase):
...
@@ -138,8 +128,8 @@ class RowFactoryTests(unittest.TestCase):
row_2
=
self
.
con
.
execute
(
"select 1 as a, 2 as b"
)
.
fetchone
()
row_2
=
self
.
con
.
execute
(
"select 1 as a, 2 as b"
)
.
fetchone
()
row_3
=
self
.
con
.
execute
(
"select 1 as a, 3 as b"
)
.
fetchone
()
row_3
=
self
.
con
.
execute
(
"select 1 as a, 3 as b"
)
.
fetchone
()
self
.
assert
True
(
row_1
==
row_1
)
self
.
assert
Equal
(
row_1
,
row_1
)
self
.
assert
True
(
row_1
==
row_2
)
self
.
assert
Equal
(
row_1
,
row_2
)
self
.
assertTrue
(
row_2
!=
row_3
)
self
.
assertTrue
(
row_2
!=
row_3
)
self
.
assertFalse
(
row_1
!=
row_1
)
self
.
assertFalse
(
row_1
!=
row_1
)
...
@@ -161,20 +151,20 @@ class TextFactoryTests(unittest.TestCase):
...
@@ -161,20 +151,20 @@ class TextFactoryTests(unittest.TestCase):
def
CheckUnicode
(
self
):
def
CheckUnicode
(
self
):
austria
=
"sterreich"
austria
=
"sterreich"
row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
self
.
assert
True
(
type
(
row
[
0
])
==
str
,
"type of row[0] must be unicode"
)
self
.
assert
Equal
(
type
(
row
[
0
]),
str
,
"type of row[0] must be unicode"
)
def
CheckString
(
self
):
def
CheckString
(
self
):
self
.
con
.
text_factory
=
bytes
self
.
con
.
text_factory
=
bytes
austria
=
"sterreich"
austria
=
"sterreich"
row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
self
.
assert
True
(
type
(
row
[
0
])
==
bytes
,
"type of row[0] must be bytes"
)
self
.
assert
Equal
(
type
(
row
[
0
]),
bytes
,
"type of row[0] must be bytes"
)
self
.
assert
True
(
row
[
0
]
==
austria
.
encode
(
"utf-8"
),
"column must equal original data in UTF-8"
)
self
.
assert
Equal
(
row
[
0
],
austria
.
encode
(
"utf-8"
),
"column must equal original data in UTF-8"
)
def
CheckCustom
(
self
):
def
CheckCustom
(
self
):
self
.
con
.
text_factory
=
lambda
x
:
str
(
x
,
"utf-8"
,
"ignore"
)
self
.
con
.
text_factory
=
lambda
x
:
str
(
x
,
"utf-8"
,
"ignore"
)
austria
=
"sterreich"
austria
=
"sterreich"
row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
self
.
assert
True
(
type
(
row
[
0
])
==
str
,
"type of row[0] must be unicode"
)
self
.
assert
Equal
(
type
(
row
[
0
]),
str
,
"type of row[0] must be unicode"
)
self
.
assertTrue
(
row
[
0
]
.
endswith
(
"reich"
),
"column must contain original data"
)
self
.
assertTrue
(
row
[
0
]
.
endswith
(
"reich"
),
"column must contain original data"
)
def
CheckOptimizedUnicode
(
self
):
def
CheckOptimizedUnicode
(
self
):
...
@@ -185,8 +175,8 @@ class TextFactoryTests(unittest.TestCase):
...
@@ -185,8 +175,8 @@ class TextFactoryTests(unittest.TestCase):
germany
=
"Deutchland"
germany
=
"Deutchland"
a_row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
a_row
=
self
.
con
.
execute
(
"select ?"
,
(
austria
,))
.
fetchone
()
d_row
=
self
.
con
.
execute
(
"select ?"
,
(
germany
,))
.
fetchone
()
d_row
=
self
.
con
.
execute
(
"select ?"
,
(
germany
,))
.
fetchone
()
self
.
assert
True
(
type
(
a_row
[
0
])
==
str
,
"type of non-ASCII row must be str"
)
self
.
assert
Equal
(
type
(
a_row
[
0
]),
str
,
"type of non-ASCII row must be str"
)
self
.
assert
True
(
type
(
d_row
[
0
])
==
str
,
"type of ASCII-only row must be str"
)
self
.
assert
Equal
(
type
(
d_row
[
0
]),
str
,
"type of ASCII-only row must be str"
)
def
tearDown
(
self
):
def
tearDown
(
self
):
self
.
con
.
close
()
self
.
con
.
close
()
...
...
Lib/sqlite3/test/hooks.py
Dosyayı görüntüle @
78ee0784
...
@@ -162,7 +162,7 @@ class ProgressTests(unittest.TestCase):
...
@@ -162,7 +162,7 @@ class ProgressTests(unittest.TestCase):
create table bar (a, b)
create table bar (a, b)
"""
)
"""
)
second_count
=
len
(
progress_calls
)
second_count
=
len
(
progress_calls
)
self
.
assert
True
(
first_count
>
second_count
)
self
.
assert
Greater
(
first_count
,
second_count
)
def
CheckCancelOperation
(
self
):
def
CheckCancelOperation
(
self
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment