• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23###########################################################################
24#
25import logging
26import os
27import sys
28from typing import Optional
29
30import pytest
31
32sys.path.append(os.path.join(os.path.dirname(__file__), '.'))
33
34from testenv import Env, Nghttpx, Httpd
35
36
37@pytest.fixture(scope="package")
38def env(pytestconfig) -> Env:
39    env = Env(pytestconfig=pytestconfig)
40    level = logging.DEBUG if env.verbose > 0 else logging.INFO
41    logging.getLogger('').setLevel(level=level)
42    env.setup()
43    return env
44
45@pytest.fixture(scope="package", autouse=True)
46def log_global_env_facts(record_testsuite_property, env):
47    record_testsuite_property("http-port", env.http_port)
48
49
50@pytest.fixture(scope='package')
51def httpd(env) -> Httpd:
52    httpd = Httpd(env=env)
53    assert httpd.exists(), f'httpd not found: {env.httpd}'
54    httpd.clear_logs()
55    assert httpd.start()
56    yield httpd
57    httpd.stop()
58
59
60@pytest.fixture(scope='package')
61def nghttpx(env, httpd) -> Optional[Nghttpx]:
62    nghttpx = Nghttpx(env=env)
63    if env.have_h3():
64        nghttpx.clear_logs()
65        assert nghttpx.start()
66    yield nghttpx
67    nghttpx.stop()
68
69