aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup.cfg7
-rw-r--r--setup.py16
-rw-r--r--setup_commands/__init__.py3
-rw-r--r--setup_commands/run_tests.py41
4 files changed, 57 insertions, 10 deletions
diff --git a/setup.cfg b/setup.cfg
index b7593ce..41d118e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,4 @@
[aliases]
-check = pytest
-unit_check = check --addopts=tests/unit
-integration_check = check --addopts=tests/integration
-performance_check = check --addopts=tests/performance
+run_unit_tests = run_tests --type=unit
+run_integration_tests = run_tests --type=integration
+run_performance_tests = run_tests --type=performance
diff --git a/setup.py b/setup.py
index a4e95d1..9396f59 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,12 @@
#!/usr/bin/env python
"""Basic setup script for gn3"""
from setuptools import setup # type: ignore
+from setup_commands import RunTests
+def long_description():
+ """Retrieve long description from the README file."""
+ with open('README.md', encoding="utf-8") as readme:
+ return readme.read()
setup(author='Bonface M. K.',
author_email='me@bonfacemunyoki.com',
@@ -23,7 +28,7 @@ setup(author='Bonface M. K.',
"flask-cors==3.0.9"
],
license='GPLV3',
- long_description=open('README.md').read(),
+ long_description=long_description(),
long_description_content_type='text/markdown',
name='gn3',
packages=[
@@ -35,8 +40,7 @@ setup(author='Bonface M. K.',
],
url='https://github.com/genenetwork/genenetwork3',
version='0.1',
- # ---- TESTING ---- #
- setup_requires=['pytest-runner'],
- tests_require=["pytest", "hypothesis"]
- # ---- END: TESTING ---- #
- )
+ tests_require=["pytest", "hypothesis"],
+ cmdclass={
+ "run_tests": RunTests ## testing
+ })
diff --git a/setup_commands/__init__.py b/setup_commands/__init__.py
new file mode 100644
index 0000000..967bb11
--- /dev/null
+++ b/setup_commands/__init__.py
@@ -0,0 +1,3 @@
+"""Module for custom setup commands."""
+
+from .run_tests import RunTests
diff --git a/setup_commands/run_tests.py b/setup_commands/run_tests.py
new file mode 100644
index 0000000..9a2c9ad
--- /dev/null
+++ b/setup_commands/run_tests.py
@@ -0,0 +1,41 @@
+import os
+import sys
+from distutils.core import Command
+
+class RunTests(Command):
+ """
+ A custom command to run tests.
+ """
+ description = "Run the tests"
+ commands = {
+ "all": "pytest",
+ "unit": "pytest tests/unit",
+ "integration": "pytest tests/integration",
+ "performance": "pytest tests/performance",
+ }
+ user_options = [
+ ("type=", None,
+ f"""Specify the type of tests to run.
+ Valid types are {tuple(commands.keys())}.
+ Default is `all`.""")]
+
+ def __init__(self, dist):
+ """Initialise the command."""
+ super().__init__(dist)
+
+ def initialize_options(self):
+ """Initialise the default values of all the options."""
+ self.type = "all"
+
+ def finalize_options(self):
+ """Set final value of all the options once they are processed."""
+ if self.type not in RunTests.commands.keys():
+ raise Exception(f"""
+ Invalid test type (self.type) requested!
+ Valid types are
+ {tuple(RunTests.commands.keys())}""")
+
+ def run(self):
+ """Run the chosen tests"""
+ print(f"Running {self.type} tests")
+ os.system(RunTests.commands[self.type])