Commit 73524573 authored by Gabriel Couture's avatar Gabriel Couture

Add a more complex and complete setup.py

parent 67a38e6a
Pipeline #182 passed with stage
in 4 seconds
......@@ -2,10 +2,12 @@
!.gitignore
!.gitlab-ci.yml
!setup.py
!requirements.txt
!README.md
!setup.py
!basic_setup.py
!main.py
!data/
......
from setuptools import setup, find_packages
setup(
name='howtotest',
version='0.1.0',
packages=find_packages(),
url='https://gitlab.physmed.chudequebec.ca//gacou54/howtotestbasic',
license='MIT',
author='Gabriel Couture',
author_email='gabriel.couture.4@ulaval.ca',
description='Example of a python project with tests',
test_suite='tests',
)
import basic_setup
import subprocess
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
LINT_COMMAND = ['./venv/bin/pycodestyle', '--ignore=E501', 'dvh', 'tests']
UNIT_TESTS_COMMAND = ['./venv/bin/python', '-m', 'unittest', 'discover', '-s', './tests/unit/']
INTEGRATION_TESTS_COMMAND = ['./venv/bin/python', '-m', 'unittest', 'discover', '-s', './tests/integration']
def _run_command(command: str) -> None:
try:
subprocess.check_call(command)
except subprocess.CalledProcessError as error:
print('Command failed with exit code', error.returncode)
exit(error.returncode)
class UnitTests(TestCommand):
description = 'run unit tests'
user_options = []
def run_tests(self):
_run_command(UNIT_TESTS_COMMAND)
class IntegrationTests(TestCommand):
description = 'run integration tests'
user_options = []
def run_tests(self):
_run_command(INTEGRATION_TESTS_COMMAND)
class LintTests(TestCommand):
description = 'run linters'
user_options = []
def run_tests(self):
_run_command(LINT_COMMAND)
class AllTests(TestCommand):
description = 'run unit tests, integration tests and linters'
user_options = []
def run_tests(self):
_run_command(UNIT_TESTS_COMMAND)
_run_command(INTEGRATION_TESTS_COMMAND)
_run_command(LINT_COMMAND)
setup(
name='howtotestbasic',
name='howtotest',
version='0.1.0',
packages=find_packages(),
url='https://gitlab.physmed.chudequebec.ca//gacou54/howtotestbasic',
license='MIT',
author='Gabriel Couture',
author_email='gabriel.couture.4@ulaval.ca',
description='Example of a basic python project with tests',
test_suite='tests',
description='Example of a python project with tests',
cmdclass={
'lint': LintTests,
'unit': UnitTests,
'integration': IntegrationTests,
'test': AllTests
},
)
# coding: utf-8
# author: gabriel couture
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment