@@ -50,39 +50,55 @@ def test_database_noaccess():
50
50
Item .objects .count ()
51
51
52
52
53
- def test_django_testrunner_verbosity_from_pytest (django_testdir ):
54
- """
55
- Test that Django's code to setup and teardown the databases uses pytest's
56
- verbosity level.
57
- """
58
- django_testdir .create_test_module ('''
59
- import pytest
60
-
61
- @pytest.mark.django_db
62
- def test_inner_testrunner():
63
- pass
64
- ''' )
65
-
66
- # Not verbose by default.
67
- result = django_testdir .runpytest ('-s' )
68
- result .stdout .fnmatch_lines ([
69
- "tpkg/test_the_test.py ." ])
70
-
71
- # -v and -q results in verbosity 0.
72
- result = django_testdir .runpytest ('-s' , '-v' , '-q' )
73
- result .stdout .fnmatch_lines ([
74
- "tpkg/test_the_test.py ." ])
75
-
76
- # Verbose output with '-v'.
77
- result = django_testdir .runpytest ('-s' , '-v' )
78
- result .stdout .fnmatch_lines_random ([
79
- "tpkg/test_the_test.py:*" ,
80
- "*PASSED*" ,
81
- "*Destroying test database for alias 'default'...*" ])
82
-
83
- # More verbose output with '-v -v'.
84
- result = django_testdir .runpytest ('-s' , '-v' , '-v' )
85
- result .stdout .fnmatch_lines_random ([
86
- "tpkg/test_the_test.py:*" ,
87
- "*PASSED*" ,
88
- "*Destroying test database for alias 'default' ('*')...*" ])
53
+ class TestrunnerVerbosity :
54
+ """Test that Django's code to setup and teardown the databases uses
55
+ pytest's verbosity level."""
56
+
57
+ @pytest .fixture
58
+ def testdir (self , django_testdir ):
59
+ print ("testdir" )
60
+ django_testdir .create_test_module ('''
61
+ import pytest
62
+
63
+ @pytest.mark.django_db
64
+ def test_inner_testrunner():
65
+ pass
66
+ ''' )
67
+ return django_testdir
68
+
69
+ def test_default (self , testdir ):
70
+ """Not verbose by default."""
71
+ result = testdir .runpytest ('-s' )
72
+ result .stdout .fnmatch_lines ([
73
+ "tpkg/test_the_test.py ." ])
74
+
75
+ def test_vq_verbosity_0 (self , testdir ):
76
+ """-v and -q results in verbosity 0."""
77
+ result = testdir .runpytest ('-s' , '-v' , '-q' )
78
+ result .stdout .fnmatch_lines ([
79
+ "tpkg/test_the_test.py ." ])
80
+
81
+ def test_verbose_with_v (self , testdir ):
82
+ """Verbose output with '-v'."""
83
+ result = testdir .runpytest ('-s' , '-v' )
84
+ result .stdout .fnmatch_lines_random ([
85
+ "tpkg/test_the_test.py:*" ,
86
+ "*PASSED*" ,
87
+ "*Destroying test database for alias 'default'...*" ])
88
+
89
+ def test_more_verbose_with_vv (self , testdir ):
90
+ """More verbose output with '-v -v'."""
91
+ result = testdir .runpytest ('-s' , '-v' , '-v' )
92
+ result .stdout .fnmatch_lines ([
93
+ "tpkg/test_the_test.py:*Creating test database for alias*" ,
94
+ "*Creating table app_item*" ,
95
+ "*PASSED*Destroying test database for alias 'default' ('*')...*" ])
96
+
97
+ def test_more_verbose_with_vv_and_reusedb (self , testdir ):
98
+ """More verbose output with '-v -v', and --reuse-db."""
99
+ result = testdir .runpytest ('-s' , '-v' , '-v' , '--reuse-db' )
100
+ result .stdout .fnmatch_lines ([
101
+ "tpkg/test_the_test.py:*Creating test database for alias*" ,
102
+ "*PASSED*" ])
103
+ assert ("*Destroying test database for alias 'default' ('*')...*"
104
+ not in result .stdout .str ())
0 commit comments