diff --git a/.github/workflows/test-lib-building.yaml b/.github/workflows/test-lib-building.yaml index acb5ee9..8fed722 100644 --- a/.github/workflows/test-lib-building.yaml +++ b/.github/workflows/test-lib-building.yaml @@ -33,4 +33,4 @@ jobs: python test_script.py - name: Verify library usage - Part II - run: pytest test/ + run: pytest tests/ diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a03feaa..a1e1c69 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -41,7 +41,7 @@ jobs: set -e # Exit immediately if a command exits with a non-zero status. set -u # Exit immediately if a variable is not defined. - docker run --rm -e COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} flask-inputfilter sh -c "coverage run --source=flask_inputfilter -m pytest test/ && coveralls" + docker run --rm -e COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }} flask-inputfilter sh -c "coverage run --source=flask_inputfilter -m pytest tests/ && coveralls" - name: Run code style checks run: | diff --git a/Dockerfile b/Dockerfile index d3d6c83..d0a2ffc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,9 @@ WORKDIR /app RUN apt-get update && apt-get install -y gcc python3-dev git -RUN pip install --upgrade pip +COPY pyproject.toml /app -COPY requirements.txt /app - -RUN pip install --no-cache-dir -r requirements.txt +RUN python -m pip install .[dev] COPY . /app diff --git a/MANIFEST.in b/MANIFEST.in index 58743ff..abf62d0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ include docs/index.rst include LICENSE include docs/changelog.rst +prune tests diff --git a/env_configs/Dockerfile b/env_configs/Dockerfile index a436ec6..873670b 100644 --- a/env_configs/Dockerfile +++ b/env_configs/Dockerfile @@ -42,10 +42,8 @@ RUN /root/.pyenv/bin/pyenv install 3.14-dev RUN /root/.pyenv/bin/pyenv global 3.7.12 3.8.12 3.9.7 3.10.2 3.11.0 3.12.0 3.13.0 3.14-dev -RUN pip install --upgrade pip +COPY pyproject.toml /app -COPY ../requirements.txt /app - -RUN pip install --no-cache-dir -r requirements.txt && pip install tox +RUN python -m pip install .[dev] && python -m pip install tox COPY .. /app diff --git a/pyproject.toml b/pyproject.toml index a49179a..ba2b6fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,63 @@ requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" +[project] +name = "flask_inputfilter" +version = "0.3.0" +description = "A library to easily filter and validate input data in Flask applications" +readme = "README.rst" +requires-python = ">=3.7" +license = {text = "MIT"} +authors = [ + {name = "Leander Cain Slotosch", email = "slotosch.leander@outlook.de"} +] +dependencies = [ + "flask>=2.1", + "typing_extensions>=3.6.2", +] +classifiers = [ + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.7", +] + +[project.optional-dependencies] +dev = [ + "autoflake", + "black", + "coverage", + "coveralls", + #"docformatter", + "flake8==5.0.4", + "flake8-pyproject==1.2.3", + "isort", + "pillow>=8.0.0", + "pytest", + "requests>=2.22.0", + "sphinx", + "sphinx-autobuild", + "sphinx_rtd_theme" +] +optional = [ + "pillow>=8.0.0", + "requests>=2.22.0", +] + +[project.urls] +Homepage = "https://github.com/LeanderCS/flask-inputfilter" +Documentation = "https://leandercs.github.io/flask-inputfilter" +Source = "https://github.com/LeanderCS/flask-inputfilter" +Issues = "https://github.com/LeanderCS/flask-inputfilter/issues" + +[tool.setuptools.packages.find] +include = ["flask_inputfilter"] + [tool.pytest.ini_options] filterwarnings = [ "ignore::DeprecationWarning" @@ -24,7 +81,7 @@ commands = source = ["flask_inputfilter"] [tool.coverage.report] -omit = ["__init__.py", "setup.py", "*/test/*"] +omit = ["__init__.py", "setup.py", "*/tests/*"] [tool.flake8] exclude = ["__init__.py", "venv", "*.md", ".*"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 03ce8e4..0000000 --- a/requirements.txt +++ /dev/null @@ -1,15 +0,0 @@ -autoflake -black -coverage -coveralls -# docformatter -flake8==5.0.4 -flake8-pyproject==1.2.3 -flask==2.1 -isort -pillow==8.0.0 -pytest -requests==2.22.0 -sphinx -sphinx-autobuild -sphinx_rtd_theme diff --git a/setup.py b/setup.py deleted file mode 100644 index 223f3ca..0000000 --- a/setup.py +++ /dev/null @@ -1,43 +0,0 @@ -from setuptools import find_packages, setup - -setup( - name="flask_inputfilter", - version="0.3.0", - license="MIT", - author="Leander Cain Slotosch", - author_email="slotosch.leander@outlook.de", - description="A library to easily filter and validate input data in " - "Flask applications", - long_description=open("README.rst").read(), - long_description_content_type="text/x-rst", - url="https://github.com/LeanderCS/flask-inputfilter", - packages=find_packages( - include=["flask_inputfilter", "flask_inputfilter.*"] - ), - install_requires=[ - "flask>=2.1", - "typing_extensions>=3.6.2", - ], - extras_require={ - "optional": [ - "pillow>=8.0.0", - "requests>=2.22.0", - ], - }, - classifiers=[ - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.14", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.7", - ], - python_requires=">=3.7", - project_urls={ - "Documentation": "https://leandercs.github.io/flask-inputfilter", - "Source": "https://github.com/LeanderCS/flask-inputfilter", - }, -) diff --git a/test/__init__.py b/tests/__init__.py similarity index 100% rename from test/__init__.py rename to tests/__init__.py diff --git a/test/data/base64_image.txt b/tests/data/base64_image.txt similarity index 100% rename from test/data/base64_image.txt rename to tests/data/base64_image.txt diff --git a/test/test_condition.py b/tests/test_condition.py similarity index 100% rename from test/test_condition.py rename to tests/test_condition.py diff --git a/test/test_filter.py b/tests/test_filter.py similarity index 98% rename from test/test_filter.py rename to tests/test_filter.py index fe233ca..23ee8b0 100644 --- a/test/test_filter.py +++ b/tests/test_filter.py @@ -87,7 +87,7 @@ def test_base64_image_downscale_filter(self) -> None: filters=[Base64ImageDownscaleFilter(size=144)], ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: validated_data = self.inputFilter.validateData( {"image": file.read()} ) @@ -96,7 +96,7 @@ def test_base64_image_downscale_filter(self) -> None: ).size self.assertEqual(size, (12, 12)) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: validated_data = self.inputFilter.validateData( { "image": Image.open( @@ -125,7 +125,7 @@ def test_base64_image_size_reduce_filter(self) -> None: filters=[Base64ImageResizeFilter(max_size=1024)], ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: validated_data = self.inputFilter.validateData( {"image": file.read()} ) @@ -138,7 +138,7 @@ def test_base64_image_size_reduce_filter(self) -> None: size = buffer.tell() self.assertLessEqual(size, 1024) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: validated_data = self.inputFilter.validateData( { "image": Image.open( diff --git a/test/test_input_filter.py b/tests/test_input_filter.py similarity index 100% rename from test/test_input_filter.py rename to tests/test_input_filter.py diff --git a/test/test_validator.py b/tests/test_validator.py similarity index 99% rename from test/test_validator.py rename to tests/test_validator.py index 95a36c3..2b36627 100644 --- a/test/test_validator.py +++ b/tests/test_validator.py @@ -685,7 +685,7 @@ def test_is_base64_image_validator(self) -> None: "image", required=True, validators=[IsBase64ImageValidator()] ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: self.inputFilter.validateData({"image": file.read()}) with self.assertRaises(ValidationError): @@ -885,7 +885,7 @@ def test_is_horizontally_image_validator(self) -> None: "image", validators=[IsHorizontalImageValidator()] ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: self.inputFilter.validateData({"image": file.read()}) with self.assertRaises(ValidationError): @@ -901,7 +901,7 @@ def test_is_horizontally_image_validator(self) -> None: validators=[IsHorizontalImageValidator()], ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: self.inputFilter.validateData({"horizontally_image": file.read()}) self.inputFilter.add( @@ -914,7 +914,7 @@ def test_is_horizontally_image_validator(self) -> None: validators=[IsHorizontalImageValidator()], ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: with self.assertRaises(ValidationError): self.inputFilter.validateData( {"vertically_image": file.read()} @@ -1265,7 +1265,7 @@ def test_is_vertically_image_validator(self) -> None: self.inputFilter.add("image", validators=[IsVerticalImageValidator()]) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: self.inputFilter.validateData({"image": file.read()}) with self.assertRaises(ValidationError): @@ -1281,7 +1281,7 @@ def test_is_vertically_image_validator(self) -> None: validators=[IsVerticalImageValidator()], ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: with self.assertRaises(ValidationError): self.inputFilter.validateData( {"horizontally_image": file.read()} @@ -1297,7 +1297,7 @@ def test_is_vertically_image_validator(self) -> None: validators=[IsVerticalImageValidator()], ) - with open("test/data/base64_image.txt", "r") as file: + with open("tests/data/base64_image.txt", "r") as file: self.inputFilter.validateData({"vertically_image": file.read()}) with self.assertRaises(ValidationError):