Skip to content

pytestコマンドだけでテストを実行できるようにする #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: python
python:
- 2.7
- 3.3
- 3.4
- 3.5
- pypy
- 3.6
- 3.7
- 3.8
- 3.9
- pypy3

install:
- pip install tox tox-travis
Expand Down
36 changes: 21 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,43 @@ TDDBC for Python with Pytest
動作確認環境
============

- Python 2.7.6
- Python 3.3.1
- PyPy 1.9.0
- PyPy 2.2.0
- Python 3.8.5
- pytest 6.2.4

※Python2は2020年1月にサポート終了(EOL)していますので、Python3をご利用ください。

セットアップ
============

以下のように実行して、環境を構築してください。

.. code-block:: sh

$ pip install -r requirements.txt
$ git clone https://github.com/yattom/python_pytest.git
$ cd python_pytest
$ pip3 install -r requirements.txt

**setup.py** を実行し
テストを実行するには **pytest** コマンドを使います。

.. code-block:: sh

$ python setup.py test
$ pytest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍


...

# Output sample
======================== test session starts =================================
platform linux2 -- Python 2.7.3[pypy-2.2.0-final] -- pytest-2.4.2
-- ~/.virtualenvs/tddbc_python_pytest_pypy22/bin/python
plugins: cov, xdist
============================= test session starts ==============================
platform linux -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /root/work/python_pytest, configfile: setup.cfg
plugins: forked-1.3.0, cov-2.11.1, xdist-2.2.1
collected 3 items

tests/acme/test_acme.py:28: TestPython.test_be_out_of_question PASSED
tests/acme/test_acme.py:41: TestMontyPython.test_say_name[Monty Python] PASSED
tests/acme/test_acme.py:41: TestMontyPython.test_say_name[John Smith] PASSED
======================== 3 passed in 0.10 seconds ============================
tests/acme/test_snake.py::TestPython::test_be_out_of_question PASSED [ 33%]
tests/acme/test_snake.py::TestMontyPython::test_say_name[Monty Python] PASSED [ 66%]
tests/acme/test_snake.py::TestMontyPython::test_say_name[John Smith] PASSED [100%]

============================== 3 passed in 0.04s ===============================

のように正常終了すればOKです

Expand Down
21 changes: 13 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
-e .
appdirs==1.4.4
cov-core==1.15.0
coverage==4.4.1
execnet==1.4.1
py==1.4.34
pytest==3.1.3
pytest-cov==2.5.1
pytest-xdist==1.18.0
tox==2.7.0
virtualenv==15.1.0
coverage==5.5
distlib==0.3.1
execnet==1.8.0
filelock==3.0.12
iniconfig==1.1.1
py==1.10.0
pytest-cov==2.11.1
pytest-xdist==2.2.1
pytest==6.2.4
tox==3.23.1
virtualenv==20.4.6
16 changes: 0 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
import sys


class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)

setup(
name='skeleton_for_pytest',
Expand All @@ -25,7 +10,6 @@ def run_tests(self):
license='MIT',
packages=find_packages(exclude=['tests']),
tests_require=['pytest'],
cmdclass={'test': PyTest},
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tox]
skipsdist = True
envlist =
py27,
py33,
py34,
py35
py36,
py37,
py38,
py39

[testenv]
deps=
-r{toxinidir}/requirements.txt
commands=
python setup.py test
pytest