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
bf4516a6
Kaydet (Commit)
bf4516a6
authored
Kas 07, 2016
tarafından
Phil Tysoe
Kaydeden (comit)
Tim Graham
Ara 22, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for django.utils.autoreload.
üst
61225ef7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
1 deletion
+68
-1
test_autoreload.py
tests/utils_tests/test_autoreload.py
+68
-1
No files found.
tests/utils_tests/test_autoreload.py
Dosyayı görüntüle @
bf4516a6
import
gettext
import
os
import
shutil
import
tempfile
...
...
@@ -5,10 +6,12 @@ from importlib import import_module
from
django
import
conf
from
django.contrib
import
admin
from
django.test
import
SimpleTestCase
,
override_settings
from
django.test
import
SimpleTestCase
,
mock
,
override_settings
from
django.test.utils
import
extend_sys_path
from
django.utils
import
autoreload
from
django.utils._os
import
npath
from
django.utils.six.moves
import
_thread
from
django.utils.translation
import
trans_real
LOCALE_PATH
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'locale'
)
...
...
@@ -184,3 +187,67 @@ class TestFilenameGenerator(SimpleTestCase):
with
self
.
assertRaises
(
Exception
):
autoreload
.
check_errors
(
import_module
)(
'test_exception'
)
self
.
assertFileFound
(
filename
)
class
CleanFilesTests
(
SimpleTestCase
):
TEST_MAP
=
{
# description: (input_file_list, expected_returned_file_list)
'falsies'
:
([
None
,
False
],
[]),
'pycs'
:
([
'myfile.pyc'
],
[
'myfile.py'
]),
'pyos'
:
([
'myfile.pyo'
],
[
'myfile.py'
]),
'$py.class'
:
([
'myclass$py.class'
],
[
'myclass.py'
]),
'combined'
:
(
[
None
,
'file1.pyo'
,
'file2.pyc'
,
'myclass$py.class'
],
[
'file1.py'
,
'file2.py'
,
'myclass.py'
],
)
}
def
_run_tests
(
self
,
mock_files_exist
=
True
):
with
mock
.
patch
(
'django.utils.autoreload.os.path.exists'
,
return_value
=
mock_files_exist
):
for
description
,
values
in
self
.
TEST_MAP
.
items
():
filenames
,
expected_returned_filenames
=
values
self
.
assertEqual
(
autoreload
.
clean_files
(
filenames
),
expected_returned_filenames
if
mock_files_exist
else
[],
msg
=
'{} failed for input file list: {}; returned file list: {}'
.
format
(
description
,
filenames
,
expected_returned_filenames
),
)
def
test_files_exist
(
self
):
"""
If the file exists, any compiled files (pyc, pyo, $py.class) are
transformed as their source files.
"""
self
.
_run_tests
()
def
test_files_do_not_exist
(
self
):
"""
If the files don't exist, they aren't in the returned file list.
"""
self
.
_run_tests
(
mock_files_exist
=
False
)
class
ResetTranslationsTests
(
SimpleTestCase
):
def
setUp
(
self
):
self
.
gettext_translations
=
gettext
.
_translations
.
copy
()
self
.
trans_real_translations
=
trans_real
.
_translations
.
copy
()
def
tearDown
(
self
):
gettext
.
_translations
=
self
.
gettext_translations
trans_real
.
_translations
=
self
.
trans_real_translations
def
test_resets_gettext
(
self
):
gettext
.
_translations
=
{
'foo'
:
'bar'
}
autoreload
.
reset_translations
()
self
.
assertEqual
(
gettext
.
_translations
,
{})
def
test_resets_trans_real
(
self
):
trans_real
.
_translations
=
{
'foo'
:
'bar'
}
trans_real
.
_default
=
1
trans_real
.
_active
=
False
autoreload
.
reset_translations
()
self
.
assertEqual
(
trans_real
.
_translations
,
{})
self
.
assertIsNone
(
trans_real
.
_default
)
self
.
assertIsInstance
(
trans_real
.
_active
,
_thread
.
_local
)
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