summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-09-03 02:24:42 +0200
committerNejc Habjan <hab.nejc@gmail.com>2021-09-03 02:43:34 +0200
commit2bb4358e37a374b36f2aa8c983ce72009d70b55d (patch)
tree31c8602a8b71c79631e516332189d8fc4b668b46
parentfe0dca2b594b2f1570d3a7d87f1684b774918cdd (diff)
downloadgitlab-fix/tests-in-wheel.tar.gz
test(build): add smoke tests for sdist & wheel packagefix/tests-in-wheel
-rw-r--r--.github/workflows/test.yml2
-rw-r--r--pyproject.toml3
-rw-r--r--tests/smoke/__init__.py0
-rw-r--r--tests/smoke/test_dists.py33
-rw-r--r--tox.ini4
5 files changed, 41 insertions, 1 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 216b43d..b1254bb 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -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 }}
diff --git a/pyproject.toml b/pyproject.toml
index 27b5faa..0d13f24 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,7 +16,8 @@ module = [
"setup",
"tests.functional.*",
"tests.functional.api.*",
- "tests.unit.*"
+ "tests.unit.*",
+ "tests.smoke.*"
]
ignore_errors = true
diff --git a/tests/smoke/__init__.py b/tests/smoke/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/smoke/__init__.py
diff --git a/tests/smoke/test_dists.py b/tests/smoke/test_dists.py
new file mode 100644
index 0000000..6f38ff7
--- /dev/null
+++ b/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()]
diff --git a/tox.ini b/tox.ini
index 1ddc331..8ba8346 100644
--- a/tox.ini
+++ b/tox.ini
@@ -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}