Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
1c5f4e86
Kaydet (Commit)
1c5f4e86
authored
Kas 13, 2015
tarafından
Simon Charette
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25745 -- Promoted RuntimeWarnings to errors in the test suite.
üst
d95b22bd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
34 deletions
+19
-34
tests.py
tests/apps/tests.py
+6
-8
tests.py
tests/backends/tests.py
+1
-0
test_graph.py
tests/migrations/test_graph.py
+2
-0
test_pickle.py
tests/model_regress/test_pickle.py
+4
-13
tests.py
tests/queryset_pickle/tests.py
+4
-13
runtests.py
tests/runtests.py
+2
-0
No files found.
tests/apps/tests.py
Dosyayı görüntüle @
1c5f4e86
from
__future__
import
unicode_literals
import
os
import
warnings
from
unittest
import
skipUnless
from
django.apps
import
AppConfig
,
apps
...
...
@@ -232,14 +231,13 @@ class AppsTests(SimpleTestCase):
body
=
{}
body
[
'Meta'
]
=
type
(
str
(
"Meta"
),
tuple
(),
meta_contents
)
body
[
'__module__'
]
=
TotallyNormal
.
__module__
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
msg
=
(
"Model 'apps.southponies' was already registered. "
"Reloading models is not advised as it can lead to inconsistencies, "
"most notably with related models."
)
with
self
.
assertRaisesMessage
(
RuntimeWarning
,
msg
):
type
(
str
(
"SouthPonies"
),
(
models
.
Model
,),
body
)
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertTrue
(
issubclass
(
w
[
-
1
]
.
category
,
RuntimeWarning
))
self
.
assertEqual
(
str
(
w
[
-
1
]
.
message
),
"Model 'apps.southponies' was already registered. "
"Reloading models is not advised as it can lead to inconsistencies, "
"most notably with related models."
)
# If it doesn't appear to be a reloaded module then we expect
# a RuntimeError.
...
...
tests/backends/tests.py
Dosyayı görüntüle @
1c5f4e86
...
...
@@ -203,6 +203,7 @@ class PostgreSQLTests(TestCase):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
mock
.
patch
(
'django.db.backends.base.base.BaseDatabaseWrapper.connect'
,
side_effect
=
mocked_connect
,
autospec
=
True
):
warnings
.
simplefilter
(
'always'
,
RuntimeWarning
)
nodb_conn
=
connection
.
_nodb_connection
self
.
assertIsNotNone
(
nodb_conn
.
settings_dict
[
'NAME'
])
self
.
assertEqual
(
nodb_conn
.
settings_dict
[
'NAME'
],
connection
.
settings_dict
[
'NAME'
])
...
...
tests/migrations/test_graph.py
Dosyayı görüntüle @
1c5f4e86
...
...
@@ -197,6 +197,7 @@ class GraphTests(SimpleTestCase):
leaf
=
expected
[
-
1
]
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'always'
,
RuntimeWarning
)
forwards_plan
=
graph
.
forwards_plan
(
leaf
)
self
.
assertEqual
(
len
(
w
),
1
)
...
...
@@ -205,6 +206,7 @@ class GraphTests(SimpleTestCase):
self
.
assertEqual
(
expected
,
forwards_plan
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
'always'
,
RuntimeWarning
)
backwards_plan
=
graph
.
backwards_plan
(
root
)
self
.
assertEqual
(
len
(
w
),
1
)
...
...
tests/model_regress/test_pickle.py
Dosyayı görüntüle @
1c5f4e86
...
...
@@ -3,13 +3,11 @@ import os
import
pickle
import
subprocess
import
sys
import
warnings
from
django.core.files.temp
import
NamedTemporaryFile
from
django.db
import
DJANGO_VERSION_PICKLE_KEY
,
models
from
django.test
import
TestCase
,
mock
from
django.utils._os
import
npath
,
upath
from
django.utils.encoding
import
force_text
from
django.utils.version
import
get_version
from
.models
import
Article
...
...
@@ -31,11 +29,9 @@ class ModelPickleTestCase(TestCase):
return
reduce_list
p
=
MissingDjangoVersion
(
title
=
"FooBar"
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
msg
=
"Pickled model instance's Django version is not specified."
with
self
.
assertRaisesMessage
(
RuntimeWarning
,
msg
):
pickle
.
loads
(
pickle
.
dumps
(
p
))
msg
=
force_text
(
recorded
.
pop
()
.
message
)
self
.
assertEqual
(
msg
,
"Pickled model instance's Django version is not specified."
)
def
test_unsupported_unpickle
(
self
):
"""
...
...
@@ -52,14 +48,9 @@ class ModelPickleTestCase(TestCase):
return
reduce_list
p
=
DifferentDjangoVersion
(
title
=
"FooBar"
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
msg
=
"Pickled model instance's Django version 1.0 does not match the current version
%
s."
%
get_version
()
with
self
.
assertRaisesMessage
(
RuntimeWarning
,
msg
):
pickle
.
loads
(
pickle
.
dumps
(
p
))
msg
=
force_text
(
recorded
.
pop
()
.
message
)
self
.
assertEqual
(
msg
,
"Pickled model instance's Django version 1.0 does not "
"match the current version
%
s."
%
get_version
()
)
def
test_unpickling_when_appregistrynotready
(
self
):
"""
...
...
tests/queryset_pickle/tests.py
Dosyayı görüntüle @
1c5f4e86
...
...
@@ -3,12 +3,10 @@ from __future__ import unicode_literals
import
datetime
import
pickle
import
unittest
import
warnings
from
django.db
import
models
from
django.test
import
TestCase
from
django.utils
import
six
from
django.utils.encoding
import
force_text
from
django.utils.version
import
get_version
from
.models
import
Container
,
Event
,
Group
,
Happening
,
M2MModel
...
...
@@ -142,11 +140,9 @@ class PickleabilityTestCase(TestCase):
unpickled without a Django version
"""
qs
=
Group
.
missing_django_version_objects
.
all
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
msg
=
"Pickled queryset instance's Django version is not specified."
with
self
.
assertRaisesMessage
(
RuntimeWarning
,
msg
):
pickle
.
loads
(
pickle
.
dumps
(
qs
))
msg
=
force_text
(
recorded
.
pop
()
.
message
)
self
.
assertEqual
(
msg
,
"Pickled queryset instance's Django version is not specified."
)
def
test_unsupported_unpickle
(
self
):
"""
...
...
@@ -154,11 +150,6 @@ class PickleabilityTestCase(TestCase):
unpickled with a different Django version than the current
"""
qs
=
Group
.
previous_django_version_objects
.
all
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
msg
=
"Pickled queryset instance's Django version 1.0 does not match the current version
%
s."
%
get_version
()
with
self
.
assertRaisesMessage
(
RuntimeWarning
,
msg
):
pickle
.
loads
(
pickle
.
dumps
(
qs
))
msg
=
force_text
(
recorded
.
pop
()
.
message
)
self
.
assertEqual
(
msg
,
"Pickled queryset instance's Django version 1.0 does not "
"match the current version
%
s."
%
get_version
()
)
tests/runtests.py
Dosyayı görüntüle @
1c5f4e86
...
...
@@ -24,6 +24,8 @@ from django.utils.log import DEFAULT_LOGGING
# Make deprecation warnings errors to ensure no usage of deprecated features.
warnings
.
simplefilter
(
"error"
,
RemovedInDjango20Warning
)
# Make runtime warning errors to ensure no usage of error prone patterns.
warnings
.
simplefilter
(
"error"
,
RuntimeWarning
)
# Ignore known warnings in test dependencies.
warnings
.
filterwarnings
(
"ignore"
,
"'U' mode is deprecated"
,
DeprecationWarning
,
module
=
'docutils.io'
)
...
...
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