From e9c3a20e099ee44d0873c1b73cb4300861cc9003 Mon Sep 17 00:00:00 2001 From: Muhammad Kaisar Arkhan Date: Sat, 30 Dec 2017 10:45:05 +0700 Subject: Use pytest to run tests Closes https://github.com/Flameeyes/glucometerutils/issues/34 --- .gitignore | 1 + setup.cfg | 15 +++++++++++++++ setup.py | 22 +++++++++++++++++++++- test-requirements.txt | 4 ++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 setup.cfg create mode 100644 test-requirements.txt diff --git a/.gitignore b/.gitignore index 894b10a..70028ed 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /MANIFEST /dist/ __pycache__/ +.cache diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..cd71828 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[tool:pytest] +addopts = + --color=yes + --ignore=setup.py + --ignore=test-requirements.txt + -r a +norecursedirs = + .git + dist + build + venv + .env +testpaths = + test +timeout = 120 diff --git a/setup.py b/setup.py index d7cc51f..c49745a 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,23 @@ # -*- coding: utf-8 -*- +import sys + from setuptools import setup, find_packages +from setuptools.command.test import test as TestCommand + + +with open('test-requirements.txt') as requirements: + test_required = requirements.read().splitlines() + + +class PyTestCommand(TestCommand): + + def run_tests(self): + # import here, cause outside the eggs aren't loaded + import pytest + errno = pytest.main([]) + sys.exit(errno) + setup( name = 'glucometerutils', @@ -27,8 +44,8 @@ setup( data_files = [ ('lib/udev/rules', ['udev/69-glucometerutils.rules']), ], + tests_require = test_required, extras_require = { - 'test': ['absl-py'], # These are all the drivers' dependencies. Optional dependencies are # listed as mandatory for the feature. 'otultra2': ['pyserial'], @@ -46,4 +63,7 @@ setup( 'glucometer=glucometerutils.glucometer:main' ] }, + cmdclass = { + 'test': PyTestCommand, + }, ) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..9f7c85b --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,4 @@ +absl-py +pytest +pytest-timeout +pyserial -- cgit v1.2.3