update for builtin plugin
This commit is contained in:
		
							parent
							
								
									c56d7ac40e
								
							
						
					
					
						commit
						63c01d1541
					
				|  | @ -126,6 +126,7 @@ default_plugins = ( | ||||||
|     "freeze_support", |     "freeze_support", | ||||||
|     "setuponly", |     "setuponly", | ||||||
|     "setupplan", |     "setupplan", | ||||||
|  |     "stepwise", | ||||||
|     "warnings", |     "warnings", | ||||||
|     "logging", |     "logging", | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -1,19 +1,18 @@ | ||||||
| from .compat import Cache, tryfirst | from _pytest.cacheprovider import Cache | ||||||
|  | import pytest | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def pytest_addoption(parser): | def pytest_addoption(parser): | ||||||
|     group = parser.getgroup('general') |     group = parser.getgroup('general') | ||||||
|     group.addoption('--sw', action='store_true', dest='stepwise', |     group.addoption('--sw', '--stepwise', action='store_true', dest='stepwise', | ||||||
|                     help='alias for --stepwise') |  | ||||||
|     group.addoption('--stepwise', action='store_true', dest='stepwise', |  | ||||||
|                     help='exit on test fail and continue from last failing test next time') |                     help='exit on test fail and continue from last failing test next time') | ||||||
|     group.addoption('--skip', action='store_true', dest='skip', |     group.addoption('--stepwise-skip', action='store_true', dest='stepwise_skip', | ||||||
|                     help='ignore the first failing test but stop on the next failing test') |                     help='ignore the first failing test but stop on the next failing test') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @tryfirst | @pytest.hookimpl(tryfirst=True) | ||||||
| def pytest_configure(config): | def pytest_configure(config): | ||||||
|     config.cache = Cache(config) |     config.cache = Cache.for_config(config) | ||||||
|     config.pluginmanager.register(StepwisePlugin(config), 'stepwiseplugin') |     config.pluginmanager.register(StepwisePlugin(config), 'stepwiseplugin') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -25,7 +24,7 @@ class StepwisePlugin: | ||||||
| 
 | 
 | ||||||
|         if self.active: |         if self.active: | ||||||
|             self.lastfailed = config.cache.get('cache/stepwise', None) |             self.lastfailed = config.cache.get('cache/stepwise', None) | ||||||
|             self.skip = config.getvalue('skip') |             self.skip = config.getvalue('stepwise_skip') | ||||||
| 
 | 
 | ||||||
|     def pytest_sessionstart(self, session): |     def pytest_sessionstart(self, session): | ||||||
|         self.session = session |         self.session = session | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ def pytest_addoption(parser): | ||||||
| ''') | ''') | ||||||
| 
 | 
 | ||||||
|     # Create a simple test suite. |     # Create a simple test suite. | ||||||
|     testdir.makepyfile(test_stepwise=''' |     testdir.makepyfile(test_a=''' | ||||||
| def test_success_before_fail(): | def test_success_before_fail(): | ||||||
|     assert 1 |     assert 1 | ||||||
| 
 | 
 | ||||||
|  | @ -30,7 +30,7 @@ def test_success_after_last_fail(): | ||||||
|     assert 1 |     assert 1 | ||||||
| ''') | ''') | ||||||
| 
 | 
 | ||||||
|     testdir.makepyfile(testfile_b=''' |     testdir.makepyfile(test_b=''' | ||||||
| def test_success(): | def test_success(): | ||||||
|     assert 1 |     assert 1 | ||||||
| ''') | ''') | ||||||
|  | @ -40,7 +40,7 @@ def test_success(): | ||||||
| 
 | 
 | ||||||
| @pytest.fixture | @pytest.fixture | ||||||
| def error_testdir(testdir): | def error_testdir(testdir): | ||||||
|     testdir.makepyfile(test_stepwise=''' |     testdir.makepyfile(test_a=''' | ||||||
| def test_error(nonexisting_fixture): | def test_error(nonexisting_fixture): | ||||||
|     assert 1 |     assert 1 | ||||||
| 
 | 
 | ||||||
|  | @ -88,7 +88,7 @@ def test_fail_and_continue_with_stepwise(stepwise_testdir): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_run_with_skip_option(stepwise_testdir): | def test_run_with_skip_option(stepwise_testdir): | ||||||
|     result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', '--skip', |     result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', '--stepwise-skip', | ||||||
|                                         '--fail', '--fail-last') |                                         '--fail', '--fail-last') | ||||||
|     assert not result.stderr.str() |     assert not result.stderr.str() | ||||||
| 
 | 
 | ||||||
|  | @ -112,7 +112,7 @@ def test_fail_on_errors(error_testdir): | ||||||
| 
 | 
 | ||||||
| def test_change_testfile(stepwise_testdir): | def test_change_testfile(stepwise_testdir): | ||||||
|     result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', '--fail', |     result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', '--fail', | ||||||
|                                         'test_stepwise.py') |                                         'test_a.py') | ||||||
|     assert not result.stderr.str() |     assert not result.stderr.str() | ||||||
| 
 | 
 | ||||||
|     stdout = result.stdout.str() |     stdout = result.stdout.str() | ||||||
|  | @ -121,7 +121,7 @@ def test_change_testfile(stepwise_testdir): | ||||||
|     # Make sure the second test run starts from the beginning, since the |     # Make sure the second test run starts from the beginning, since the | ||||||
|     # test to continue from does not exist in testfile_b. |     # test to continue from does not exist in testfile_b. | ||||||
|     result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', |     result = stepwise_testdir.runpytest('-v', '--strict', '--stepwise', | ||||||
|                                         'testfile_b.py') |                                         'test_b.py') | ||||||
|     assert not result.stderr.str() |     assert not result.stderr.str() | ||||||
| 
 | 
 | ||||||
|     stdout = result.stdout.str() |     stdout = result.stdout.str() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue