Skip to content
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

[pull] master from thombashi:master #6

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
eb66006
Refactor clean target calls
thombashi Oct 30, 2021
6b693a1
Refactor command executions
thombashi Oct 30, 2021
ab0a9b0
Remove a lint that no longer needed
thombashi Oct 30, 2021
286f94e
Add lower version limit to cleanpy deps
thombashi Oct 30, 2021
c972e17
Update sponsors
thombashi Feb 27, 2022
a572f8f
Fix CI
thombashi Feb 27, 2022
e38c2e9
Fix CI
thombashi Feb 27, 2022
0ff3ccb
Fix CI
thombashi Feb 27, 2022
db11211
Remove clean from envlist
thombashi Jul 8, 2023
3f1754c
Remove basepython from testenvs
thombashi Jul 8, 2023
1d1a2ac
Drop support for Python 3.5
thombashi Jul 8, 2023
7bb6fe5
Modify to use testenv.extras
thombashi Jul 8, 2023
d3edae0
Modify to use Python 3.6 syntax
thombashi Jul 8, 2023
b0616c0
Remove tests/__init__.py that is no longer needed
thombashi Jul 8, 2023
de308b1
Apply formatter
thombashi Jul 8, 2023
9044735
Update test_requirements
thombashi Jul 8, 2023
f7d6bc4
Add tool.pytest.ini_options to pyproject.toml
thombashi Jul 8, 2023
db31613
Update deps of testenvs
thombashi Jul 8, 2023
cce7837
Update [build-system]
thombashi Jul 8, 2023
7314e37
Add --depth to 'git clone' execution
thombashi Jul 8, 2023
b46b2df
Update pypy specifier
thombashi Jul 8, 2023
03d7a7c
Add push-ignore to trigger events
thombashi Jul 8, 2023
73f9d43
Update actions version
thombashi Jul 8, 2023
8badaee
Modify release target
thombashi Jul 8, 2023
85b0afe
Add setup-ci target to Makefile
thombashi Jul 8, 2023
049be36
Refactor pip caching of workflows
thombashi Jul 8, 2023
b49d60b
Drop support for Python 3.6
thombashi Jul 8, 2023
e5e3982
Add target-version to tool.black
thombashi Jul 8, 2023
5ec8d27
Update an example
thombashi Jul 8, 2023
464176b
Modify to use pypa/build for package build
thombashi Jul 8, 2023
571c178
Replace deprecated setup.py calls
thombashi Jul 8, 2023
0b0bedc
Add support for Python 3.11
thombashi Jul 8, 2023
5dceef9
Add concurrency.group to unit-test job
thombashi Jul 8, 2023
8a2b46d
Remove name from a step
thombashi Jul 8, 2023
cab4490
Add lint job to CI
thombashi Jul 8, 2023
944b170
Add build-package job to CI
thombashi Jul 8, 2023
c1316f8
Update README
thombashi Jul 8, 2023
fb5c9a4
Bump version
thombashi Jul 8, 2023
b575786
Fix release target
thombashi Jul 8, 2023
415a2d2
Update testenv:lint
thombashi Jul 8, 2023
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
87 changes: 59 additions & 28 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,83 @@
name: Tests

on: [push, pull_request]
on:
push:
paths-ignore:
- '.gitignore'
- 'README.rst'
pull_request:
paths-ignore:
- '.gitignore'
- 'README.rst'

jobs:
build:
build-package:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref_name }}-build
cancel-in-progress: true
timeout-minutes: 20
container:
image: ghcr.io/thombashi/python-ci:3.11

steps:
- uses: actions/checkout@v3

- run: make build

lint:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref_name }}-lint
cancel-in-progress: true
timeout-minutes: 20
container:
image: ghcr.io/thombashi/python-ci:3.11

steps:
- uses: actions/checkout@v3

- run: make check

unit-test:
timeout-minutes: 20
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref_name }}-ut-${{ matrix.os }}-${{ matrix.python-version }}
cancel-in-progress: true
strategy:
fail-fast: false
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, 3.10.0-alpha.6, pypy3]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.10']
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
setup.py
**/*requirements.txt
tox.ini

- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade "pip>=20.1"
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ matrix.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-pip-
- name: Install pip
run: python -m pip install --upgrade --disable-pip-version-check "pip>=21.1"

- name: Install dependencies
run: |
python -m pip install --upgrade tox
- run: make setup-ci

- name: Run tox
run: |
tox -e cov
- name: Run tests
run: tox -e cov
env:
PYTEST_DISCORD_WEBHOOK: ${{ secrets.PYTEST_DISCORD_WEBHOOK }}

- name: Coverage report
- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8'
run: |
python -m pip install --upgrade coveralls
python -m pip install --upgrade --disable-pip-version-check coveralls tomli
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8'
36 changes: 19 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,46 @@ PACKAGE := allpairspy
BUILD_WORK_DIR := _work
DIST_DIR := $(BUILD_WORK_DIR)/$(PACKAGE)/dist
PKG_BUILD_DIR := $(BUILD_WORK_DIR)/$(PACKAGE)
PYTHON := python3


.PHONY: build
build:
@make clean
@tox -e build
build: clean
@$(PYTHON) -m tox -e build
ls -lh dist/*

.PHONY: build-remote
build-remote:
build-remote:
@rm -rf $(BUILD_WORK_DIR)
build-remote: clean
@mkdir -p $(BUILD_WORK_DIR)
@cd $(BUILD_WORK_DIR) && \
git clone https://github.com/$(OWNER)/$(PACKAGE).git && \
git clone --depth 1 https://github.com/$(OWNER)/$(PACKAGE).git && \
cd $(PACKAGE) && \
tox -e build
$(PYTHON) -m tox -e build
ls -lh $(PKG_BUILD_DIR)/dist/*

.PHONY: check
check:
@tox -e lint
travis lint
@$(PYTHON) -m tox -e lint

.PHONY: clean
clean:
@tox -e clean
@rm -rf $(BUILD_WORK_DIR)
@$(PYTHON) -m tox -e clean

.PHONY: fmt
fmt:
tox -e fmt
$(PYTHON) -m tox -e fmt

.PHONY: release
release:
@cd $(PKG_BUILD_DIR) && python setup.py release --sign
@make clean
cd $(PKG_BUILD_DIR) && $(PYTHON) setup.py release --verbose
$(MAKE) clean

.PHONY: setup-ci
setup-ci:
@$(PYTHON) -m pip install -q --disable-pip-version-check --upgrade tox

.PHONY: setup
setup:
@pip install --upgrade -e .[test] releasecmd tox
pip check
setup: setup-ci
@$(PYTHON) -m pip install -q --disable-pip-version-check --upgrade -e .[test] releasecmd
@$(PYTHON) -m pip check
18 changes: 12 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Basic Usage

Filtering
==================
You can restrict pairs by setting filtering function to ``filter_func`` at
You can restrict pairs by setting a filtering function to ``filter_func`` at
``AllPairs`` constructor.

:Sample Code:
Expand Down Expand Up @@ -198,10 +198,10 @@ Pairs will be returned as ``collections.namedtuple`` instances.
11: Pairs(brand='Brand X', os='2000', minute=15)


Parameterized testing with pairwise by using pytest
Parameterized testing pairwise by using pytest
====================================================================

Parameterized testing: valee matrix
Parameterized testing: value matrix
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Sample Code:
.. code:: python
Expand Down Expand Up @@ -319,14 +319,20 @@ Known issues

Dependencies
------------
Python 3.5+
Python 3.7+
no external dependencies.


Sponsors
------------
.. image:: https://avatars0.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4
.. image:: https://avatars.githubusercontent.com/u/3658062?s=48&v=4
:target: https://github.com/b4tman
:alt: Dmitry Belyaev (b4tman)
.. image:: https://avatars.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4
:target: https://github.com/chasbecker
:alt: chasbecker
:alt: Charles Becker (chasbecker)
.. image:: https://avatars.githubusercontent.com/u/46711571?s=48&u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5&v=4
:target: https://github.com/Arturi0
:alt: Arturi0

`Become a sponsor <https://github.com/sponsors/thombashi>`__
2 changes: 1 addition & 1 deletion allpairspy/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
__maintainer__ = "Tsuyoshi Hombashi"
__maintainer_email__ = "[email protected]"
__license__ = "MIT License"
__version__ = "2.5.0"
__version__ = "2.5.1"
4 changes: 2 additions & 2 deletions allpairspy/allpairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def __next__(self):
continue
direction = 0
else:
raise ValueError("next(): unknown 'direction' code '{}'".format(direction))
raise ValueError(f"next(): unknown 'direction' code '{direction}'")

chosen_item_list[i] = self.__working_item_matrix[i][indexes[i]]

Expand Down Expand Up @@ -202,7 +202,7 @@ def __resort_working_array(self, chosen_item_list, num):
def __get_working_item_matrix(self, parameter_matrix):
return [
[
Item("a{:d}v{:d}".format(param_idx, value_idx), value)
Item(f"a{param_idx:d}v{value_idx:d}", value)
for value_idx, value in enumerate(value_list)
]
for param_idx, value_list in enumerate(parameter_matrix)
Expand Down
2 changes: 1 addition & 1 deletion examples/example1.1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

print("PAIRWISE:")
for i, pairs in enumerate(AllPairs(parameters)):
print("{:2d}: {}".format(i, pairs))
print(f"{i:2d}: {pairs}")
2 changes: 1 addition & 1 deletion examples/example1.2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

print("TRIPLEWISE:")
for i, pairs in enumerate(AllPairs(parameters, n=3)):
print("{:2d}: {}".format(i, pairs))
print(f"{i:2d}: {pairs}")
2 changes: 1 addition & 1 deletion examples/example1.3.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

print("PAIRWISE:")
for i, pairs in enumerate(AllPairs(parameters, previously_tested=tested)):
print("{:2d}: {}".format(i, pairs))
print(f"{i:2d}: {pairs}")
2 changes: 1 addition & 1 deletion examples/example2.1.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def is_valid_combination(row):

print("PAIRWISE:")
for i, pairs in enumerate(AllPairs(parameters, filter_func=is_valid_combination)):
print("{:2d}: {}".format(i, pairs))
print(f"{i:2d}: {pairs}")
3 changes: 1 addition & 2 deletions examples/example2.2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


def is_valid_combination(values, names):

dictionary = dict(zip(names, values))

"""
Expand Down Expand Up @@ -56,4 +55,4 @@ def is_valid_combination(values, names):

print("PAIRWISE:")
for i, pairs in enumerate(pairwise):
print("{:2d}: {}".format(i, pairs))
print(f"{i:2d}: {pairs}")
8 changes: 6 additions & 2 deletions examples/example_ordered_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@


parameters = OrderedDict(
{"brand": ["Brand X", "Brand Y"], "os": ["98", "NT", "2000", "XP"], "minute": [15, 30, 60]}
{
"brand": ["Brand X", "Brand Y"],
"os": ["98", "NT", "2000", "XP"],
"minute": [15, 30, 60],
}
)

print("PAIRWISE:")
for i, pairs in enumerate(AllPairs(parameters)):
print("{:2d}: {}".format(i, pairs))
print(f"{i:2d}: {pairs}")
6 changes: 3 additions & 3 deletions examples/test_parameterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from allpairspy import AllPairs


def function_to_be_tested(brand, operating_system, minute):
def function_to_be_tested(brand: str, operating_system: str, minute: int) -> bool:
# do something

return True
Expand All @@ -19,8 +19,8 @@ class TestParameterized:
@pytest.mark.parametrize(
["brand", "operating_system", "minute"],
[
value_list
for value_list in AllPairs(
values
for values in AllPairs(
[["Brand X", "Brand Y"], ["98", "NT", "2000", "XP"], [10, 15, 30, 60]]
)
],
Expand Down
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 100
Expand All @@ -18,6 +19,7 @@ exclude = '''
)/
| docs/conf.py
'''
target-version = ['py37', 'py38', 'py39', 'py310']

[tool.coverage.run]
source = ['allpairspy']
Expand Down Expand Up @@ -49,3 +51,12 @@ skip_glob = [
'*/.pytype/*',
'*/.tox/*',
]

[tool.pytest.ini_options]
testpaths = [
"tests",
]

md_report = true
md_report_verbose = 0
md_report_color = "auto"
3 changes: 2 additions & 1 deletion requirements/test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest
pytest>=6.0.1
pytest-md-report>=0.3
12 changes: 7 additions & 5 deletions setup.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


MODULE_NAME = "allpairspy"
REPOSITORY_URL = "https://github.com/thombashi/{:s}".format(MODULE_NAME)
REPOSITORY_URL = f"https://github.com/thombashi/{MODULE_NAME:s}"
REQUIREMENT_DIR = "requirements"

pkg_info = {}
Expand Down Expand Up @@ -44,8 +44,11 @@ def get_release_command_class():
maintainer=pkg_info["__maintainer__"],
maintainer_email=pkg_info["__maintainer_email__"],
packages=setuptools.find_packages(exclude=["tests*"]),
project_urls={"Source": REPOSITORY_URL, "Tracker": "{:s}/issues".format(REPOSITORY_URL)},
python_requires=">=3.5",
project_urls={
"Source": REPOSITORY_URL,
"Tracker": f"{REPOSITORY_URL:s}/issues",
},
python_requires=">=3.7",
install_requires=install_requires,
extras_require={"test": tests_requires},
classifiers=[
Expand All @@ -59,12 +62,11 @@ def get_release_command_class():
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
Expand Down
3 changes: 0 additions & 3 deletions tests/__init__.py

This file was deleted.

Loading