conftest.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 2008 - 2022, 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. #
  25. import sys, os
  26. sys.path.append(os.path.join(os.path.dirname(__file__), 'http'))
  27. import pytest
  28. from testenv import Env
  29. def pytest_report_header(config, startdir):
  30. # Env inits its base properties only once, we can report them here
  31. env = Env()
  32. report = [
  33. f'Testing curl {env.curl_version()}',
  34. f' httpd: {env.httpd_version()}, http:{env.http_port} https:{env.https_port}',
  35. f' httpd-proxy: {env.httpd_version()}, http:{env.proxy_port} https:{env.proxys_port}'
  36. ]
  37. if env.have_h3():
  38. report.extend([
  39. f' nghttpx: {env.nghttpx_version()}, h3:{env.https_port}'
  40. ])
  41. if env.has_caddy():
  42. report.extend([
  43. f' Caddy: {env.caddy_version()}, http:{env.caddy_http_port} https:{env.caddy_https_port}'
  44. ])
  45. return '\n'.join(report)
  46. def pytest_addoption(parser):
  47. parser.addoption("--repeat", action="store", type=int, default=1,
  48. help='Number of times to repeat each test')
  49. def pytest_generate_tests(metafunc):
  50. if "repeat" in metafunc.fixturenames:
  51. count = int(metafunc.config.getoption("repeat"))
  52. metafunc.fixturenames.append('tmp_ct')
  53. metafunc.parametrize('repeat', range(count))