From 4c6ed996034e2e80b1561322cb28536f4f1f1798 Mon Sep 17 00:00:00 2001 From: Danny Hajj Date: Fri, 17 Nov 2023 17:10:23 +0100 Subject: [PATCH 1/4] Replace obsolete test libraries with pytest --- .github/workflows/python.yml | 2 +- personnummer/tests/test_personnummer.py | 3 ++- setup.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index dd6f242..cecb92b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false max-parallel: 1 matrix: - python-version: [3.7, 3.8, 3.9] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/personnummer/tests/test_personnummer.py b/personnummer/tests/test_personnummer.py index c1b9f9a..edecac5 100644 --- a/personnummer/tests/test_personnummer.py +++ b/personnummer/tests/test_personnummer.py @@ -1,9 +1,10 @@ from datetime import datetime from unittest import TestCase +from unittest import mock + from personnummer import personnummer import urllib.request import json -import mock def get_test_data(): diff --git a/setup.py b/setup.py index 410feb4..84be96a 100644 --- a/setup.py +++ b/setup.py @@ -9,8 +9,8 @@ author_email='hello@personnummer.dev', license='MIT', packages=['personnummer'], - test_suite='nose.collector', - tests_require=['nose', 'mock'], + test_suite='pytest', + tests_require=['pytest'], entry_points={ 'console_scripts': ['personnummer = personnummer.main:main'] }, From c906d54bd43a700fc8b493463192e434ec056891 Mon Sep 17 00:00:00 2001 From: Danny Hajj Date: Fri, 24 Nov 2023 11:04:17 +0100 Subject: [PATCH 2/4] Migrate from setup.py to pyproject.toml --- .github/workflows/python.yml | 6 +++--- pyproject.toml | 40 ++++++++++++++++++++++++++++++++++++ setup.py | 19 +++-------------- 3 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index cecb92b..811e16c 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -28,6 +28,6 @@ jobs: pip install -U setuptools - name: Run tests run: | - python setup.py clean --all - python setup.py install - python -W all setup.py test + pip install .[dev] + pytest + python -m build diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3fe1497 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +[build-system] +requires = ["setuptools>=61.2", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +version = "3.0.6" +name = "personnummer" +description = "Validate Swedish personal identity numbers" +license = { file = "./LICENSE" } +authors = [ + { name = "Personnummer and Contributors", email = "hello@personnummer.dev" }, +] + +[project.urls] +homepage = "https://personnummer.dev" +repository = "https://github.com/personnummer/python" + +[project.entry-points."console_scripts"] +personnummer = "personnummer.main:main" + +[project.optional-dependencies] +dev = [ + "pytest", + "build", +] + +[options] +packages = ["personnummer"] + +[tool.setuptools] +include-package-data = false + +[tool.setuptools.packages.find] +exclude = ["personnummer/tests*"] + +[tool.pytest.ini_options] +testpaths = [ + "personnummer/tests", +] +addopts = "-ra -v" diff --git a/setup.py b/setup.py index 84be96a..1abbd06 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,4 @@ -from setuptools import setup +import setuptools -setup( - name='personnummer', - version='3.0.6', - description='Validate Swedish personal identity numbers', - url='http://github.com/personnummer/python', - author='Personnummer and Contributors', - author_email='hello@personnummer.dev', - license='MIT', - packages=['personnummer'], - test_suite='pytest', - tests_require=['pytest'], - entry_points={ - 'console_scripts': ['personnummer = personnummer.main:main'] - }, -) +if __name__ == "__main__": + setuptools.setup() From 3120f961352e9822911fce1d1c2bdc6e292138c8 Mon Sep 17 00:00:00 2001 From: Danny Hajj Date: Fri, 24 Nov 2023 11:29:44 +0100 Subject: [PATCH 3/4] Bump version to 3.1.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3fe1497..4be6cf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"] build-backend = "setuptools.build_meta" [project] -version = "3.0.6" +version = "3.1.0" name = "personnummer" description = "Validate Swedish personal identity numbers" license = { file = "./LICENSE" } From 5fe784d3dc8f8bff83b1b4c89480686022c6319f Mon Sep 17 00:00:00 2001 From: Danny Hajj Date: Fri, 24 Nov 2023 16:25:49 +0100 Subject: [PATCH 4/4] Configure the readme in pyproject.toml --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 4be6cf4..ece43a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,7 @@ version = "3.1.0" name = "personnummer" description = "Validate Swedish personal identity numbers" license = { file = "./LICENSE" } +readme = "README.md" authors = [ { name = "Personnummer and Contributors", email = "hello@personnummer.dev" }, ]