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
ea4e0aad
Kaydet (Commit)
ea4e0aad
authored
May 31, 2012
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Cleaned up test_client_regress tests
üst
4553f511
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
31 deletions
+13
-31
tests.py
tests/regressiontests/test_client_regress/tests.py
+11
-28
views.py
tests/regressiontests/test_client_regress/views.py
+2
-3
No files found.
tests/regressiontests/test_client_regress/tests.py
Dosyayı görüntüle @
ea4e0aad
...
...
@@ -17,14 +17,10 @@ from django.template.response import SimpleTemplateResponse
from
django.http
import
HttpResponse
@override_settings
(
TEMPLATE_DIRS
=
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'templates'
),)
)
class
AssertContainsTests
(
TestCase
):
def
setUp
(
self
):
self
.
old_templates
=
settings
.
TEMPLATE_DIRS
settings
.
TEMPLATE_DIRS
=
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'templates'
),)
def
tearDown
(
self
):
settings
.
TEMPLATE_DIRS
=
self
.
old_templates
def
test_contains
(
self
):
"Responses can be inspected for content, including counting repeated substrings"
response
=
self
.
client
.
get
(
'/test_client_regress/no_template_view/'
)
...
...
@@ -544,17 +540,13 @@ class LoginTests(TestCase):
self
.
assertRedirects
(
response
,
"http://testserver/test_client_regress/get_view/"
)
@override_settings
(
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,))
@override_settings
(
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,),
SESSION_ENGINE
=
'regressiontests.test_client_regress.session'
)
class
SessionEngineTests
(
TestCase
):
fixtures
=
[
'testdata'
]
def
setUp
(
self
):
self
.
old_SESSION_ENGINE
=
settings
.
SESSION_ENGINE
settings
.
SESSION_ENGINE
=
'regressiontests.test_client_regress.session'
def
tearDown
(
self
):
settings
.
SESSION_ENGINE
=
self
.
old_SESSION_ENGINE
def
test_login
(
self
):
"A session engine that modifies the session key can be used to log in"
login
=
self
.
client
.
login
(
username
=
'testclient'
,
password
=
'password'
)
...
...
@@ -616,6 +608,8 @@ class ExceptionTests(TestCase):
except
SuspiciousOperation
:
self
.
fail
(
"Staff should be able to visit this page"
)
@override_settings
(
TEMPLATE_DIRS
=
())
class
TemplateExceptionTests
(
TestCase
):
def
setUp
(
self
):
# Reset the loaders so they don't try to render cached templates.
...
...
@@ -623,11 +617,6 @@ class TemplateExceptionTests(TestCase):
for
template_loader
in
loader
.
template_source_loaders
:
if
hasattr
(
template_loader
,
'reset'
):
template_loader
.
reset
()
self
.
old_templates
=
settings
.
TEMPLATE_DIRS
settings
.
TEMPLATE_DIRS
=
()
def
tearDown
(
self
):
settings
.
TEMPLATE_DIRS
=
self
.
old_templates
def
test_no_404_template
(
self
):
"Missing templates are correctly reported by test client"
...
...
@@ -980,11 +969,8 @@ class RequestFactoryStateTest(TestCase):
# run the tests individually, and if any are failing it is confusing to run
# them with any other set of tests.
def
setUp
(
self
):
self
.
factory
=
RequestFactory
()
def
common_test_that_should_always_pass
(
self
):
request
=
self
.
factory
.
get
(
'/'
)
request
=
RequestFactory
()
.
get
(
'/'
)
request
.
session
=
{}
self
.
assertFalse
(
hasattr
(
request
,
'user'
))
...
...
@@ -1007,11 +993,8 @@ class RequestFactoryEnvironmentTests(TestCase):
are set correctly in RequestFactory.
"""
def
setUp
(
self
):
self
.
factory
=
RequestFactory
()
def
test_should_set_correct_env_variables
(
self
):
request
=
self
.
factory
.
get
(
'/path/'
)
request
=
RequestFactory
()
.
get
(
'/path/'
)
self
.
assertEqual
(
request
.
META
.
get
(
'REMOTE_ADDR'
),
'127.0.0.1'
)
self
.
assertEqual
(
request
.
META
.
get
(
'SERVER_NAME'
),
'testserver'
)
...
...
tests/regressiontests/test_client_regress/views.py
Dosyayı görüntüle @
ea4e0aad
...
...
@@ -5,7 +5,6 @@ from django.contrib.auth.decorators import login_required
from
django.http
import
HttpResponse
,
HttpResponseRedirect
from
django.core.exceptions
import
SuspiciousOperation
from
django.shortcuts
import
render_to_response
from
django.utils.encoding
import
smart_str
from
django.core.serializers.json
import
DjangoJSONEncoder
from
django.test.client
import
CONTENT_TYPE_RE
from
django.template
import
RequestContext
...
...
@@ -84,8 +83,8 @@ def return_json_file(request):
obj_json
=
json
.
dumps
(
obj_dict
,
encoding
=
charset
,
cls
=
DjangoJSONEncoder
,
ensure_ascii
=
False
)
response
=
HttpResponse
(
smart_str
(
obj_json
,
encoding
=
charset
),
status
=
200
,
mimetype
=
'application/json; charset=
'
+
charset
)
response
=
HttpResponse
(
obj_json
.
encode
(
charset
),
status
=
200
,
mimetype
=
'application/json; charset=
%
s'
%
charset
)
response
[
'Content-Disposition'
]
=
'attachment; filename=testfile.json'
return
response
...
...
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