Changeset - 92653a85a87e
[Not reviewed]
stable
0 1 0
Mads Kiilerich (mads) - 3 years ago 2023-04-20 10:33:39
mads@kiilerich.com
Grafted from: 33c322a3c282
tests: address PytestDeprecationWarning for @pytest.yield_fixture

Adhere to the warning:

kallithea/tests/conftest.py:207: PytestDeprecationWarning: @pytest.yield_fixture is deprecated.
Use @pytest.fixture instead; they are the same.
@pytest.yield_fixture(scope="session")
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/conftest.py
Show inline comments
 
@@ -183,34 +183,34 @@ def test_context_fixture(app_fixture):
 
    class, use the following class decorator:
 
        @pytest.mark.usefixtures("test_context_fixture")
 
        class TestFoo(TestController):
 
            ...
 
    """
 
    with test_context(app_fixture):
 
        yield
 

	
 

	
 
class MyWSGIServer(WSGIServer):
 
    def repo_url(self, repo_name, username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS):
 
        """Return URL to repo on this web server."""
 
        host, port = self.server_address
 
        proto = 'http' if self._server.ssl_context is None else 'https'
 
        auth = ''
 
        if username is not None:
 
            auth = username
 
            if password is not None:
 
                auth += ':' + password
 
        if auth:
 
            auth += '@'
 
        return '%s://%s%s:%s/%s' % (proto, auth, host, port, repo_name)
 

	
 

	
 
@pytest.yield_fixture(scope="session")
 
@pytest.fixture(scope="session")
 
def webserver():
 
    """Start web server while tests are running.
 
    Useful for debugging and necessary for vcs operation tests."""
 
    server = MyWSGIServer(application=kallithea.tests.base.testapp)
 
    server.start()
 

	
 
    yield server
 

	
 
    server.stop()
0 comments (0 inline, 0 general)