From f89ba097a9053848f45b50f62fa3a67c6648e30e Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Fri, 12 Mar 2021 14:13:43 +0800 Subject: [PATCH] add simple test script --- .github/workflows/ci.yml | 13 +++++++++-- .gitignore | 1 + .pdm.toml | 2 -- pdm.lock | 49 ++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 14 +++++++----- test.py | 30 ++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 10 deletions(-) delete mode 100644 .pdm.toml create mode 100644 pdm.lock create mode 100644 test.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03af540..6c8e0eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,7 @@ on: [push] +name: Test Action + jobs: Testing: runs-on: ubuntu-latest @@ -14,5 +16,12 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Get the project info - run: pdm info + - name: Install dependencies + run: pdm install -d -v + env: + LD_PRELOAD: /lib/x86_64-linux-gnu/libgcc_s.so.1 + + - name: Verify python version + run: pdm run python test.py + env: + PYTHON_VERSION: ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 0fff78c..69cb8de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ yarn.lock __pypackages__/ +.pdm.toml diff --git a/.pdm.toml b/.pdm.toml deleted file mode 100644 index 00c4908..0000000 --- a/.pdm.toml +++ /dev/null @@ -1,2 +0,0 @@ -[python] -path = "/Users/fming/Library/PythonUp/cmd/python3.8" diff --git a/pdm.lock b/pdm.lock new file mode 100644 index 0000000..4252788 --- /dev/null +++ b/pdm.lock @@ -0,0 +1,49 @@ +[[package]] +name = "certifi" +sections = ["dev"] +version = "2020.12.5" +marker = "python_version < '3.10' and python_version >= '3.9'" +summary = "Python package for providing Mozilla's CA Bundle." + +[[package]] +name = "chardet" +sections = ["dev"] +version = "3.0.4" +marker = "python_version >= '3.7' and python_version < '3.8'" +summary = "Universal encoding detector for Python 2 and 3" + +[[package]] +name = "idna" +sections = ["dev"] +version = "2.10" +marker = "python_version >= '3.6' and python_version < '3.7'" +summary = "Internationalized Domain Names in Applications (IDNA)" + +[[package]] +name = "urllib3" +sections = ["dev"] +version = "1.25.11" +marker = "python_version >= '3.8' and python_version < '3.9'" +summary = "HTTP library with thread-safe connection pooling, file post, and more." + +[metadata] +lock_version = "2" +content_hash = "sha256:09666cab51d1049e60d580a53402036be799c6d7511cefc532de171f40280497" + +[metadata.files] +"certifi 2020.12.5" = [ + {file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"}, + {file = "certifi-2020.12.5.tar.gz", hash = "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"}, +] +"chardet 3.0.4" = [ + {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"}, + {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"}, +] +"idna 2.10" = [ + {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, + {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, +] +"urllib3 1.25.11" = [ + {file = "urllib3-1.25.11-py2.py3-none-any.whl", hash = "sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e"}, + {file = "urllib3-1.25.11.tar.gz", hash = "sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2"}, +] diff --git a/pyproject.toml b/pyproject.toml index 15b14ab..8bf349c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,15 @@ [project] -name = "" -version = "" -description = "" authors = [ {name = "Frost Ming", email = "mianghong@gmail.com"}, ] -dependencies = [] -dev-dependencies = [] -requires-python = ">=3.8" +dev-dependencies = [ + "idna; python_version=='3.6'", + "chardet; python_version=='3.7'", + "urllib3; python_version=='3.8'", + "certifi; python_version=='3.9'", +] +include = "test.py" +requires-python = ">=3.6" dynamic = ["classifiers"] license = {text = "MIT"} diff --git a/test.py b/test.py new file mode 100644 index 0000000..13bdd6a --- /dev/null +++ b/test.py @@ -0,0 +1,30 @@ +import os +import sys +import unittest +import importlib + + +PACKAGE_MAP = {"3.6": "idna", "3.7": "chardet", "3.8": "urllib3", "3.9": "certifi"} + + +class TestActionSuite(unittest.TestCase): + def test_check_python_version(self): + self.assertEqual( + ".".join(map(str, sys.version_info[:2])), os.getenv("PYTHON_VERSION") + ) + + def test_check_dependencies(self): + python_version = ".".join(map(str, sys.version_info[:2])) + for package in PACKAGE_MAP.values(): + if package != PACKAGE_MAP[python_version]: + self.assertRaises( + ModuleNotFoundError, + importlib.import_module, + package, + ) + else: + importlib.import_module(package) + + +if __name__ == "__main__": + unittest.main()