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
09530e61
Kaydet (Commit)
09530e61
authored
Ara 01, 2017
tarafından
Will Ayd
Kaydeden (comit)
Tim Graham
Ock 09, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28869 -- Made tagged test classes and methods inherit tags from parents.
üst
acd3baf2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
1 deletion
+66
-1
AUTHORS
AUTHORS
+1
-0
utils.py
django/test/utils.py
+4
-1
spelling_wordlist
docs/spelling_wordlist
+1
-0
tools.txt
docs/topics/testing/tools.txt
+19
-0
test_discover_runner.py
tests/test_runner/test_discover_runner.py
+12
-0
tests_inheritance.py
tests/test_runner_apps/tagged/tests_inheritance.py
+29
-0
No files found.
AUTHORS
Dosyayı görüntüle @
09530e61
...
@@ -832,6 +832,7 @@ answer newbie questions, and generally made Django that much better:
...
@@ -832,6 +832,7 @@ answer newbie questions, and generally made Django that much better:
Wiktor Kołodziej <wiktor@pykonik.org>
Wiktor Kołodziej <wiktor@pykonik.org>
Wiley Kestner <wiley.kestner@gmail.com>
Wiley Kestner <wiley.kestner@gmail.com>
Wiliam Alves de Souza <wiliamsouza83@gmail.com>
Wiliam Alves de Souza <wiliamsouza83@gmail.com>
Will Ayd <william.ayd@icloud.com>
William Schwartz <wkschwartz@gmail.com>
William Schwartz <wkschwartz@gmail.com>
Will Hardy <django@willhardy.com.au>
Will Hardy <django@willhardy.com.au>
Wilson Miner <wminer@gmail.com>
Wilson Miner <wminer@gmail.com>
...
...
django/test/utils.py
Dosyayı görüntüle @
09530e61
...
@@ -831,6 +831,9 @@ class isolate_apps(TestContextDecorator):
...
@@ -831,6 +831,9 @@ class isolate_apps(TestContextDecorator):
def
tag
(
*
tags
):
def
tag
(
*
tags
):
"""Decorator to add tags to a test class or method."""
"""Decorator to add tags to a test class or method."""
def
decorator
(
obj
):
def
decorator
(
obj
):
setattr
(
obj
,
'tags'
,
set
(
tags
))
if
hasattr
(
obj
,
'tags'
):
obj
.
tags
=
obj
.
tags
.
union
(
tags
)
else
:
setattr
(
obj
,
'tags'
,
set
(
tags
))
return
obj
return
obj
return
decorator
return
decorator
docs/spelling_wordlist
Dosyayı görüntüle @
09530e61
...
@@ -695,6 +695,7 @@ subviews
...
@@ -695,6 +695,7 @@ subviews
subwidget
subwidget
subwidgets
subwidgets
superclass
superclass
superclasses
superset
superset
swappable
swappable
symlink
symlink
...
...
docs/topics/testing/tools.txt
Dosyayı görüntüle @
09530e61
...
@@ -1619,6 +1619,25 @@ You can also tag a test case::
...
@@ -1619,6 +1619,25 @@ You can also tag a test case::
class SampleTestCase(TestCase):
class SampleTestCase(TestCase):
...
...
Subclasses inherit tags from superclasses, and methods inherit tags from their
class. Given::
@tag('foo')
class SampleTestCaseChild(SampleTestCase):
@tag('bar')
def test(self):
...
``SampleTestCaseChild.test`` will be labeled with ``'slow'``, ``'core'``,
``'bar'``, and ``'foo'``.
.. versionchanged:: 2.1
In older versions, tagged tests don't inherit tags from classes, and
tagged subclasses don't inherit tags from superclasses. For example,
``SampleTestCaseChild.test`` is labeled only with ``'bar'``.
Then you can choose which tests to run. For example, to run only fast tests:
Then you can choose which tests to run. For example, to run only fast tests:
.. code-block:: console
.. code-block:: console
...
...
tests/test_runner/test_discover_runner.py
Dosyayı görüntüle @
09530e61
...
@@ -198,3 +198,15 @@ class DiscoverRunnerTest(TestCase):
...
@@ -198,3 +198,15 @@ class DiscoverRunnerTest(TestCase):
self
.
assertEqual
(
runner
.
build_suite
([
'test_runner_apps.tagged.tests'
])
.
countTestCases
(),
0
)
self
.
assertEqual
(
runner
.
build_suite
([
'test_runner_apps.tagged.tests'
])
.
countTestCases
(),
0
)
runner
=
DiscoverRunner
(
exclude_tags
=
[
'slow'
])
runner
=
DiscoverRunner
(
exclude_tags
=
[
'slow'
])
self
.
assertEqual
(
runner
.
build_suite
([
'test_runner_apps.tagged.tests'
])
.
countTestCases
(),
0
)
self
.
assertEqual
(
runner
.
build_suite
([
'test_runner_apps.tagged.tests'
])
.
countTestCases
(),
0
)
def
test_tag_inheritance
(
self
):
def
count_tests
(
**
kwargs
):
suite
=
DiscoverRunner
(
**
kwargs
)
.
build_suite
([
'test_runner_apps.tagged.tests_inheritance'
])
return
suite
.
countTestCases
()
self
.
assertEqual
(
count_tests
(
tags
=
[
'foo'
]),
4
)
self
.
assertEqual
(
count_tests
(
tags
=
[
'bar'
]),
2
)
self
.
assertEqual
(
count_tests
(
tags
=
[
'baz'
]),
2
)
self
.
assertEqual
(
count_tests
(
tags
=
[
'foo'
],
exclude_tags
=
[
'bar'
]),
2
)
self
.
assertEqual
(
count_tests
(
tags
=
[
'foo'
],
exclude_tags
=
[
'bar'
,
'baz'
]),
1
)
self
.
assertEqual
(
count_tests
(
exclude_tags
=
[
'foo'
]),
0
)
tests/test_runner_apps/tagged/tests_inheritance.py
0 → 100644
Dosyayı görüntüle @
09530e61
from
unittest
import
TestCase
from
django.test
import
tag
@tag
(
'foo'
)
class
FooBase
(
TestCase
):
pass
class
Foo
(
FooBase
):
def
test_no_new_tags
(
self
):
pass
@tag
(
'baz'
)
def
test_new_func_tag
(
self
):
pass
@tag
(
'bar'
)
class
FooBar
(
FooBase
):
def
test_new_class_tag_only
(
self
):
pass
@tag
(
'baz'
)
def
test_new_class_and_func_tags
(
self
):
pass
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