Change fixture argument handling tests to unit-tests
This commit is contained in:
		
							parent
							
								
									6918d07560
								
							
						
					
					
						commit
						df46afc96d
					
				|  | @ -4108,54 +4108,34 @@ def test_fixture_named_request(testdir): | ||||||
| 
 | 
 | ||||||
| def test_fixture_duplicated_arguments(testdir): | def test_fixture_duplicated_arguments(testdir): | ||||||
|     """Raise error if there are positional and keyword arguments for the same parameter (#1682).""" |     """Raise error if there are positional and keyword arguments for the same parameter (#1682).""" | ||||||
|     testdir.makepyfile( |     with pytest.raises(TypeError) as excinfo: | ||||||
|         """ |  | ||||||
|         import pytest |  | ||||||
| 
 | 
 | ||||||
|         with pytest.raises(TypeError) as excinfo: |         @pytest.fixture("session", scope="session") | ||||||
|  |         def arg(arg): | ||||||
|  |             pass | ||||||
| 
 | 
 | ||||||
|             @pytest.fixture("session", scope="session") |     assert ( | ||||||
|             def arg(arg): |         str(excinfo.value) | ||||||
|                 pass |         == "The fixture arguments are defined as positional and keyword: scope. " | ||||||
| 
 |         "Use only keyword arguments." | ||||||
|         def test_error(): |  | ||||||
|             assert ( |  | ||||||
|                 str(excinfo.value) |  | ||||||
|                 == "The fixture arguments are defined as positional and keyword: scope. " |  | ||||||
|                 "Use only keyword arguments." |  | ||||||
|             ) |  | ||||||
| 
 |  | ||||||
|     """ |  | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     reprec = testdir.inline_run() |  | ||||||
|     reprec.assertoutcome(passed=1) |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| def test_fixture_with_positionals(testdir): | def test_fixture_with_positionals(testdir): | ||||||
|     """Raise warning, but the positionals should still works (#1682).""" |     """Raise warning, but the positionals should still works (#1682).""" | ||||||
|     testdir.makepyfile( |     from _pytest.deprecated import FIXTURE_POSITIONAL_ARGUMENTS | ||||||
|         """ |  | ||||||
|         import os |  | ||||||
| 
 | 
 | ||||||
|         import pytest |     with pytest.warns(pytest.PytestDeprecationWarning) as warnings: | ||||||
|         from _pytest.deprecated import FIXTURE_POSITIONAL_ARGUMENTS |  | ||||||
| 
 | 
 | ||||||
|         with pytest.warns(pytest.PytestDeprecationWarning) as warnings: |         @pytest.fixture("function", [0], True) | ||||||
|             @pytest.fixture("function", [0], True) |         def arg(monkeypatch): | ||||||
|             def arg(monkeypatch): |             monkeypatch.setenv("AUTOUSE_WORKS", "1") | ||||||
|                 monkeypatch.setenv("AUTOUSE_WORKS", "1") |  | ||||||
| 
 | 
 | ||||||
|  |     assert str(warnings[0].message) == str(FIXTURE_POSITIONAL_ARGUMENTS) | ||||||
| 
 | 
 | ||||||
|         def test_autouse(): |     assert arg._pytestfixturefunction.scope == "function" | ||||||
|             assert os.environ.get("AUTOUSE_WORKS") == "1" |     assert arg._pytestfixturefunction.params == (0,) | ||||||
|             assert str(warnings[0].message) == str(FIXTURE_POSITIONAL_ARGUMENTS) |     assert arg._pytestfixturefunction.autouse | ||||||
| 
 |  | ||||||
|     """ |  | ||||||
|     ) |  | ||||||
| 
 |  | ||||||
|     reprec = testdir.inline_run() |  | ||||||
|     reprec.assertoutcome(passed=1) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_indirect_fixture_does_not_break_scope(testdir): | def test_indirect_fixture_does_not_break_scope(testdir): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue