|
25 | 25 | import json |
26 | 26 | import os |
27 | 27 | import re |
| 28 | +import subprocess |
28 | 29 | import warnings |
29 | 30 | import zipfile |
30 | 31 | from typing import Tuple, Union |
@@ -499,12 +500,17 @@ def remove_implicit_resolver(cls, tag_to_remove): |
499 | 500 | # Construct the HTTP and Elasticsearch client |
500 | 501 | http = urllib3.PoolManager(retries=urllib3.Retry(total=10)) |
501 | 502 |
|
502 | | - yaml_tests_url = ( |
503 | | - "https://api.github.com/repos/elastic/elasticsearch-clients-tests/zipball/main" |
504 | | - ) |
| 503 | + branch = subprocess.getoutput("git branch --show-current") |
| 504 | + yaml_tests_url = f"https://api.github.com/repos/elastic/elasticsearch-clients-tests/zipball/{branch}" |
| 505 | + response = http.request("GET", yaml_tests_url) |
| 506 | + if response.status == 404 and branch != "main": |
| 507 | + # this branch does not exist in the yaml tests repo, so we use main instead |
| 508 | + branch = "main" |
| 509 | + yaml_tests_url = f"https://api.github.com/repos/elastic/elasticsearch-clients-tests/zipball/{branch}" |
| 510 | + response = http.request("GET", yaml_tests_url) |
505 | 511 |
|
506 | 512 | # Download the zip and start reading YAML from the files in memory |
507 | | - package_zip = zipfile.ZipFile(io.BytesIO(http.request("GET", yaml_tests_url).data)) |
| 513 | + package_zip = zipfile.ZipFile(io.BytesIO(response.data)) |
508 | 514 |
|
509 | 515 | for yaml_file in package_zip.namelist(): |
510 | 516 | if not re.match(r"^.*\/tests\/.*\.ya?ml$", yaml_file): |
@@ -549,7 +555,7 @@ def remove_implicit_resolver(cls, tag_to_remove): |
549 | 555 | for prefix in ("rest-api-spec/", "test/", "free/", "platinum/"): |
550 | 556 | if pytest_test_name.startswith(prefix): |
551 | 557 | pytest_test_name = pytest_test_name[len(prefix) :] |
552 | | - pytest_param_id = "%s[%d]" % (pytest_test_name, test_number) |
| 558 | + pytest_param_id = "[%s]%s[%d]" % (branch, pytest_test_name, test_number) |
553 | 559 |
|
554 | 560 | pytest_param = { |
555 | 561 | "setup": setup_steps, |
|
0 commit comments