From aa98aa8b40c8caa5e49d23ddcb895d7dbe6bec51 Mon Sep 17 00:00:00 2001 From: yattom Date: Tue, 7 Jul 2020 07:59:45 +0900 Subject: [PATCH 01/15] update requirements.txt to latest versions --- requirements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index ab0619b..b213abb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ 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 +coverage==5.2 +execnet==1.7.1 +py==1.9.0 +pytest==5.4.3 +pytest-cov==2.10.0 +pytest-xdist==1.32.0 tox==2.7.0 -virtualenv==15.1.0 +virtualenv==20.0.25 From 94ccd92b2d9e41f487f2e493efc37c807e048d98 Mon Sep 17 00:00:00 2001 From: yattom Date: Tue, 7 Jul 2020 08:34:22 +0900 Subject: [PATCH 02/15] update README to latest versions --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index e5ae659..dc41711 100644 --- a/README.rst +++ b/README.rst @@ -9,10 +9,10 @@ TDDBC for Python with Pytest 動作確認環境 ============ -- Python 2.7.6 -- Python 3.3.1 -- PyPy 1.9.0 -- PyPy 2.2.0 +- Python 3.8.0 +- pytest 5.4.3 + +※Python2は2020年1月にサポート終了(EOL)していますので、Python3をご利用ください。 セットアップ ============ From ddc44e06f8a2e4605427360c3666b801e31616dd Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 15:53:27 +0900 Subject: [PATCH 03/15] fix python versions --- .travis.yml | 7 +++---- tox.ini | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index e798535..6c1bf0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: python python: - - 2.7 - - 3.3 - - 3.4 - - 3.5 + - 3.6 + - 3.7 + - 3.8 - pypy install: diff --git a/tox.ini b/tox.ini index 2d3a29c..b2a5d91 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,9 @@ [tox] skipsdist = True envlist = - py27, - py33, - py34, - py35 + py36, + py37, + py38 [testenv] deps= From ab8bd842c3dd1ef7f1d3b67ef641d0220c0e5690 Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 16:15:36 +0900 Subject: [PATCH 04/15] use latest modules --- requirements.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index b213abb..04dac95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,13 @@ +appdirs==1.4.4 cov-core==1.15.0 -coverage==5.2 -execnet==1.7.1 -py==1.9.0 -pytest==5.4.3 -pytest-cov==2.10.0 -pytest-xdist==1.32.0 -tox==2.7.0 -virtualenv==20.0.25 +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 From 652d920119335d92228263b2db2dd1c098823a37 Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 16:18:08 +0900 Subject: [PATCH 05/15] support Python3.9 --- .travis.yml | 3 ++- tox.ini | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6c1bf0e..936f566 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,8 @@ python: - 3.6 - 3.7 - 3.8 - - pypy + - 3.9 + - pypy3 install: - pip install tox tox-travis diff --git a/tox.ini b/tox.ini index b2a5d91..864ad4d 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,8 @@ skipsdist = True envlist = py36, py37, - py38 + py38, + py39 [testenv] deps= From 55b09cdae93aab339b169d71cb670cf95d64fbe9 Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 16:26:51 +0900 Subject: [PATCH 06/15] update README --- README.rst | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index dc41711..6cefb68 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ TDDBC for Python with Pytest 動作確認環境 ============ -- Python 3.8.0 +- Python 3.8.5 - pytest 5.4.3 ※Python2は2020年1月にサポート終了(EOL)していますので、Python3をご利用ください。 @@ -19,27 +19,28 @@ TDDBC for Python with Pytest .. code-block:: sh - $ pip install -r requirements.txt + $ pip3 install -r requirements.txt **setup.py** を実行し .. code-block:: sh - $ python setup.py test + $ python3 setup.py test ... # 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.05s =============================== のように正常終了すればOKです From c1d5feb4ff058507fa03d55a4191664e61668a91 Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 16:56:19 +0900 Subject: [PATCH 07/15] correct pytest version in README --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 6cefb68..a9be70f 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,7 @@ TDDBC for Python with Pytest ============ - Python 3.8.5 -- pytest 5.4.3 +- pytest 6.2.4 ※Python2は2020年1月にサポート終了(EOL)していますので、Python3をご利用ください。 From 3856cd862cc32b122f4724a40bd927a1db6eae21 Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 17:02:15 +0900 Subject: [PATCH 08/15] to make command 'pytest' usable --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 04dac95..8f8cbf6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +-e . appdirs==1.4.4 cov-core==1.15.0 coverage==5.5 From b954c59a7530ae22739e086ee6e2f3dbbb07bca7 Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 17:18:38 +0900 Subject: [PATCH 09/15] running 'python setup.py test' is deprecated --- setup.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/setup.py b/setup.py index 4687786..d13886d 100644 --- a/setup.py +++ b/setup.py @@ -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', @@ -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', From 9c797d01b591a0b967f8d62b60809a5ce330381e Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 17:29:24 +0900 Subject: [PATCH 10/15] tox use 'pytest' to run tests --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 864ad4d..117cff9 100644 --- a/tox.ini +++ b/tox.ini @@ -10,4 +10,4 @@ envlist = deps= -r{toxinidir}/requirements.txt commands= - python setup.py test + pytest From f21afd5cd3e002bf640a5fd04c1429259543c06c Mon Sep 17 00:00:00 2001 From: yattom Date: Mon, 10 May 2021 17:43:10 +0900 Subject: [PATCH 11/15] update README to use pytest command --- README.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index a9be70f..110816f 100644 --- a/README.rst +++ b/README.rst @@ -17,15 +17,19 @@ TDDBC for Python with Pytest セットアップ ============ +以下のように実行して、環境を構築してください。 + .. code-block:: sh + $ git clone https://github.com/yattom/python_pytest.git + $ cd python_pytest $ pip3 install -r requirements.txt -**setup.py** を実行し +テストを実行するには **pytest** コマンドを使います。 .. code-block:: sh - $ python3 setup.py test + $ pytest ... @@ -40,7 +44,8 @@ TDDBC for Python with Pytest 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.05s =============================== + + ============================== 3 passed in 0.04s =============================== のように正常終了すればOKです From 28c5e68e9365cd1b0052113e847a7a476d996806 Mon Sep 17 00:00:00 2001 From: yattom Date: Tue, 11 May 2021 10:42:43 +0900 Subject: [PATCH 12/15] drop support for tox and Travis CI --- .travis.yml | 14 -------------- README.rst | 2 +- requirements.txt | 11 ----------- setup.cfg | 9 --------- tox.ini | 13 ------------- 5 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 .travis.yml delete mode 100644 setup.cfg delete mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 936f566..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: python -python: - - 3.6 - - 3.7 - - 3.8 - - 3.9 - - pypy3 - -install: - - pip install tox tox-travis - - pip install coverage coveralls - -script: - - tox -r diff --git a/README.rst b/README.rst index 110816f..80d24be 100644 --- a/README.rst +++ b/README.rst @@ -38,7 +38,7 @@ TDDBC for Python with Pytest 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 + plugins: cov-2.11.1 collected 3 items tests/acme/test_snake.py::TestPython::test_be_out_of_question PASSED [ 33%] diff --git a/requirements.txt b/requirements.txt index 8f8cbf6..d79fbe7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,3 @@ -e . -appdirs==1.4.4 -cov-core==1.15.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 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 937a34d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[metadata] -license-file = LICENSE - -[wheel] -universal = 1 - -[tool:pytest] -addopts = -rsxX -v tests acme -norecursedirs = .git diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 117cff9..0000000 --- a/tox.ini +++ /dev/null @@ -1,13 +0,0 @@ -[tox] -skipsdist = True -envlist = - py36, - py37, - py38, - py39 - -[testenv] -deps= - -r{toxinidir}/requirements.txt -commands= - pytest From 2975789766a7043b29f6a1ce4ebdfda4c9237cf7 Mon Sep 17 00:00:00 2001 From: yattom Date: Tue, 11 May 2021 11:10:31 +0900 Subject: [PATCH 13/15] update README --- README.rst | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 80d24be..ffe7f8b 100644 --- a/README.rst +++ b/README.rst @@ -30,14 +30,30 @@ TDDBC for Python with Pytest .. code-block:: sh $ pytest - ... + # Output sample + ============================= test session starts ============================== + platform linux -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 + rootdir: /root/work/python_pytest + plugins: cov-2.11.1 + collected 3 items + tests/acme/test_snake.py ... [100%] + ============================== 3 passed in 0.03s =============================== + +のように正常終了すればOKです + +実行したテストを1つずつ表示するには **-v** オプションを使います。 + +.. code-block:: sh + + $ pytest -v + ... # Output sample ============================= test session starts ============================== - platform linux -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3 + platform linux -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /root/work/python_pytest/.venv/bin/python3 cachedir: .pytest_cache - rootdir: /root/work/python_pytest, configfile: setup.cfg + rootdir: /root/work/python_pytest plugins: cov-2.11.1 collected 3 items @@ -47,7 +63,6 @@ TDDBC for Python with Pytest ============================== 3 passed in 0.04s =============================== -のように正常終了すればOKです ライセンス ========== From c76f24fee42550bed167d2f1f34a533d43e1d050 Mon Sep 17 00:00:00 2001 From: yattom Date: Tue, 11 May 2021 11:39:06 +0900 Subject: [PATCH 14/15] more plain simple tests --- tests/acme/test_snake.py | 60 +++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/tests/acme/test_snake.py b/tests/acme/test_snake.py index 33a20d8..dbd49d6 100644 --- a/tests/acme/test_snake.py +++ b/tests/acme/test_snake.py @@ -5,39 +5,37 @@ サンプルテスト """ -import re - - -def pytest_generate_tests(metafunc): - """ - Parametrizing test methods through per-class configuration - http://pytest.org/latest-ja/example/parametrize.html#id5 - """ - try: - funcarglist = metafunc.cls.params[metafunc.function.__name__] - except AttributeError: - return - argnames = list(funcarglist[0]) - metafunc.parametrize( - argnames, - [[funcargs[name] for name in argnames] for funcargs in funcarglist] - ) +import pytest +from acme.snake import Python, MontyPython + +def test_python_hisses(): + sut = Python() + actual = sut.say() + assert 'Hello' not in actual, 'PythonはHelloと言わない' -class TestPython: - def test_be_out_of_question(self): - from acme.snake import Python - assert re.match(r'^(Hiss\!)+$', Python().say()), 'シャー' + +@pytest.fixture +def monty_python(): + return MontyPython() class TestMontyPython: - params = { - 'test_say_name': [ - dict(name='Monty Python'), - dict(name='John Smith'), - ], - } - - def test_say_name(self, name): - from acme.snake import MontyPython - assert MontyPython().say(name) == 'Hello ' + name + def test_say_name_guido(self, monty_python): + actual = monty_python.say('Guido') + assert actual == 'Hello Guido' + + def test_say_name_kent(self, monty_python): + actual = monty_python.say('Kent') + assert actual == 'Hello Kent' + + @pytest.mark.parametrize( + "name, expected", + [ + ('Terry', 'Hello Terry'), + ('John', 'Hello John'), + ] + ) + def test_say_name(self, monty_python, name, expected): + actual = monty_python.say(name) + assert actual == expected From f2be2c1b59b4a1094f9658583be7f0ffcce7cf45 Mon Sep 17 00:00:00 2001 From: yattom Date: Tue, 11 May 2021 11:53:43 +0900 Subject: [PATCH 15/15] update README --- README.rst | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index ffe7f8b..a212547 100644 --- a/README.rst +++ b/README.rst @@ -36,10 +36,11 @@ TDDBC for Python with Pytest platform linux -- Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 rootdir: /root/work/python_pytest plugins: cov-2.11.1 - collected 3 items + collected 5 items - tests/acme/test_snake.py ... [100%] - ============================== 3 passed in 0.03s =============================== + tests/acme/test_snake.py ..... [100%] + + ============================== 5 passed in 0.04s =============================== のように正常終了すればOKです @@ -55,13 +56,15 @@ TDDBC for Python with Pytest cachedir: .pytest_cache rootdir: /root/work/python_pytest plugins: cov-2.11.1 - collected 3 items + collected 5 items - 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%] + tests/acme/test_snake.py::test_python_hisses PASSED [ 20%] + tests/acme/test_snake.py::TestMontyPython::test_say_name_guido PASSED [ 40%] + tests/acme/test_snake.py::TestMontyPython::test_say_name_kent PASSED [ 60%] + tests/acme/test_snake.py::TestMontyPython::test_say_name[Terry-Hello Terry] PASSED [ 80%] + tests/acme/test_snake.py::TestMontyPython::test_say_name[John-Hello John] PASSED [100%] - ============================== 3 passed in 0.04s =============================== + ============================== 5 passed in 0.05s =============================== ライセンス