Merge pull request #5068 from blueyed/reportchars
Add support for reportchars=A (`-rA`)
This commit is contained in:
		
						commit
						19035f4b55
					
				| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary.
 | 
				
			||||||
| 
						 | 
					@ -235,7 +235,8 @@ Example:
 | 
				
			||||||
    FAILED test_example.py::test_fail
 | 
					    FAILED test_example.py::test_fail
 | 
				
			||||||
    = 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds =
 | 
					    = 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds =
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes".
 | 
					The ``-r`` options accepts a number of characters after it, with ``a`` used
 | 
				
			||||||
 | 
					above meaning "all except passes".
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Here is the full list of available characters that can be used:
 | 
					Here is the full list of available characters that can be used:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -247,6 +248,7 @@ Here is the full list of available characters that can be used:
 | 
				
			||||||
 - ``p`` - passed
 | 
					 - ``p`` - passed
 | 
				
			||||||
 - ``P`` - passed with output
 | 
					 - ``P`` - passed with output
 | 
				
			||||||
 - ``a`` - all except ``pP``
 | 
					 - ``a`` - all except ``pP``
 | 
				
			||||||
 | 
					 - ``A`` - all
 | 
				
			||||||
 | 
					
 | 
				
			||||||
More than one character can be used, so for example to only see failed and skipped tests, you can execute:
 | 
					More than one character can be used, so for example to only see failed and skipped tests, you can execute:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,11 +82,11 @@ def pytest_addoption(parser):
 | 
				
			||||||
        dest="reportchars",
 | 
					        dest="reportchars",
 | 
				
			||||||
        default="",
 | 
					        default="",
 | 
				
			||||||
        metavar="chars",
 | 
					        metavar="chars",
 | 
				
			||||||
        help="show extra test summary info as specified by chars (f)ailed, "
 | 
					        help="show extra test summary info as specified by chars: (f)ailed, "
 | 
				
			||||||
        "(E)error, (s)skipped, (x)failed, (X)passed, "
 | 
					        "(E)rror, (s)kipped, (x)failed, (X)passed, "
 | 
				
			||||||
        "(p)passed, (P)passed with output, (a)all except pP. "
 | 
					        "(p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. "
 | 
				
			||||||
        "Warnings are displayed at all times except when "
 | 
					        "Warnings are displayed at all times except when "
 | 
				
			||||||
        "--disable-warnings is set",
 | 
					        "--disable-warnings is set.",
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    group._addoption(
 | 
					    group._addoption(
 | 
				
			||||||
        "--disable-warnings",
 | 
					        "--disable-warnings",
 | 
				
			||||||
| 
						 | 
					@ -167,10 +167,13 @@ def getreportopt(config):
 | 
				
			||||||
        reportchars = reportchars.replace("w", "")
 | 
					        reportchars = reportchars.replace("w", "")
 | 
				
			||||||
    if reportchars:
 | 
					    if reportchars:
 | 
				
			||||||
        for char in reportchars:
 | 
					        for char in reportchars:
 | 
				
			||||||
            if char not in reportopts and char != "a":
 | 
					            if char == "a":
 | 
				
			||||||
                reportopts += char
 | 
					 | 
				
			||||||
            elif char == "a":
 | 
					 | 
				
			||||||
                reportopts = "sxXwEf"
 | 
					                reportopts = "sxXwEf"
 | 
				
			||||||
 | 
					            elif char == "A":
 | 
				
			||||||
 | 
					                reportopts = "sxXwEfpP"
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					            elif char not in reportopts:
 | 
				
			||||||
 | 
					                reportopts += char
 | 
				
			||||||
    return reportopts
 | 
					    return reportopts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -831,14 +831,23 @@ def test_getreportopt():
 | 
				
			||||||
    config.option.reportchars = "sfxw"
 | 
					    config.option.reportchars = "sfxw"
 | 
				
			||||||
    assert getreportopt(config) == "sfx"
 | 
					    assert getreportopt(config) == "sfx"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    config.option.reportchars = "sfx"
 | 
					    # Now with --disable-warnings.
 | 
				
			||||||
    config.option.disable_warnings = False
 | 
					    config.option.disable_warnings = False
 | 
				
			||||||
 | 
					    config.option.reportchars = "a"
 | 
				
			||||||
 | 
					    assert getreportopt(config) == "sxXwEf"  # NOTE: "w" included!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    config.option.reportchars = "sfx"
 | 
				
			||||||
    assert getreportopt(config) == "sfxw"
 | 
					    assert getreportopt(config) == "sfxw"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    config.option.reportchars = "sfxw"
 | 
					    config.option.reportchars = "sfxw"
 | 
				
			||||||
    config.option.disable_warnings = False
 | 
					 | 
				
			||||||
    assert getreportopt(config) == "sfxw"
 | 
					    assert getreportopt(config) == "sfxw"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    config.option.reportchars = "a"
 | 
				
			||||||
 | 
					    assert getreportopt(config) == "sxXwEf"  # NOTE: "w" included!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    config.option.reportchars = "A"
 | 
				
			||||||
 | 
					    assert getreportopt(config) == "sxXwEfpP"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_terminalreporter_reportopt_addopts(testdir):
 | 
					def test_terminalreporter_reportopt_addopts(testdir):
 | 
				
			||||||
    testdir.makeini("[pytest]\naddopts=-rs")
 | 
					    testdir.makeini("[pytest]\naddopts=-rs")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue