Skip to content

Commit

Permalink
test(build): add smoke tests for sdist & wheel package
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch authored and JohnVillalovos committed Sep 3, 2021
1 parent 969dccc commit b8a47ba
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -25,6 +25,8 @@ jobs:
toxenv: py38
- python-version: 3.9
toxenv: py39
- python-version: 3.9
toxenv: smoke
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Expand Up @@ -16,7 +16,8 @@ module = [
"setup",
"tests.functional.*",
"tests.functional.api.*",
"tests.unit.*"
"tests.unit.*",
"tests.smoke.*"
]
ignore_errors = true

Expand Down
Empty file added tests/smoke/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions tests/smoke/test_dists.py
@@ -0,0 +1,33 @@
import tarfile
import zipfile
from pathlib import Path
from sys import version_info

import pytest
from setuptools import sandbox

from gitlab import __title__, __version__

DIST_DIR = Path("dist")
TEST_DIR = "tests"
SDIST_FILE = f"{__title__}-{__version__}.tar.gz"
WHEEL_FILE = (
f"{__title__.replace('-', '_')}-{__version__}-py{version_info.major}-none-any.whl"
)


@pytest.fixture(scope="function")
def build():
sandbox.run_setup("setup.py", ["clean", "--all"])
return sandbox.run_setup("setup.py", ["sdist", "bdist_wheel"])


def test_sdist_includes_tests(build):
sdist = tarfile.open(DIST_DIR / SDIST_FILE, "r:gz")
test_dir = sdist.getmember(f"{__title__}-{__version__}/{TEST_DIR}")
assert test_dir.isdir()


def test_wheel_excludes_tests(build):
wheel = zipfile.ZipFile(DIST_DIR / WHEEL_FILE)
assert [not file.startswith(TEST_DIR) for file in wheel.namelist()]
4 changes: 4 additions & 0 deletions tox.ini
Expand Up @@ -96,3 +96,7 @@ commands =
deps = -r{toxinidir}/requirements-docker.txt
commands =
pytest --cov --cov-report xml tests/functional/api {posargs}

[testenv:smoke]
deps = -r{toxinidir}/requirements-test.txt
commands = pytest tests/smoke {posargs}

0 comments on commit b8a47ba

Please sign in to comment.