Skip to content

Commit 40ec2f5

Browse files
committed
chore: use helper fixtures for test directories
1 parent 27109ca commit 40ec2f5

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

tools/functional/conftest.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
import gitlab
1111

1212

13-
TEMP_DIR = tempfile.gettempdir()
14-
TEST_DIR = Path(__file__).resolve().parent
15-
16-
1713
def reset_gitlab(gl):
1814
# previously tools/reset_gitlab.py
1915
for project in gl.projects.list():
@@ -27,8 +23,8 @@ def reset_gitlab(gl):
2723
user.delete()
2824

2925

30-
def set_token(container):
31-
set_token_rb = TEST_DIR / "fixtures" / "set_token.rb"
26+
def set_token(container, rootdir):
27+
set_token_rb = rootdir / "fixtures" / "set_token.rb"
3228

3329
with open(set_token_rb, "r") as f:
3430
set_token_command = f.read().strip()
@@ -47,8 +43,18 @@ def set_token(container):
4743

4844

4945
@pytest.fixture(scope="session")
50-
def docker_compose_file():
51-
return TEST_DIR / "fixtures" / "docker-compose.yml"
46+
def temp_dir():
47+
return Path(tempfile.gettempdir())
48+
49+
50+
@pytest.fixture(scope="session")
51+
def test_dir(pytestconfig):
52+
return pytestconfig.rootdir / "tools" / "functional"
53+
54+
55+
@pytest.fixture(scope="session")
56+
def docker_compose_file(test_dir):
57+
return test_dir / "fixtures" / "docker-compose.yml"
5258

5359

5460
@pytest.fixture(scope="session")
@@ -78,15 +84,15 @@ def _check(container):
7884

7985

8086
@pytest.fixture(scope="session")
81-
def gitlab_config(check_is_alive, docker_ip, docker_services):
82-
config_file = Path(TEMP_DIR) / "python-gitlab.cfg"
87+
def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, test_dir):
88+
config_file = temp_dir / "python-gitlab.cfg"
8389
port = docker_services.port_for("gitlab", 80)
8490

8591
docker_services.wait_until_responsive(
8692
timeout=180, pause=5, check=lambda: check_is_alive("gitlab-test")
8793
)
8894

89-
token = set_token("gitlab-test")
95+
token = set_token("gitlab-test", rootdir=test_dir)
9096

9197
config = f"""[global]
9298
default = local

tools/functional/python_test_v4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
qG2ZdhHHmSK2LaQLFiSprUkikStNU9BqSQ==
5858
=5OGa
5959
-----END PGP PUBLIC KEY BLOCK-----"""
60-
AVATAR_PATH = Path(__file__).resolve().parent / "fixtures" / "avatar.png"
60+
AVATAR_PATH = Path(__file__).parent / "fixtures" / "avatar.png"
6161
TEMP_DIR = Path(tempfile.gettempdir())
6262

6363
# token authentication from config file

0 commit comments

Comments
 (0)