diff --git a/.coveragerc b/.coveragerc index 0f1b93d..5724e30 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,7 +5,7 @@ branch = False # branch = True omit = - multipart/tests/* + tests/* [report] # Regexes for lines to exclude from consideration diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index d35bfa7..63078f7 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,7 +10,7 @@ name: Upload Python Package on: push: - tags: + tags: - '[0-9]+.[0-9]+.[0-9]+.*' # Run on every git tag with semantic versioning. i.e: 1.5.0 or 1.5.0rc1 permissions: diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 864fc99..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,4 +0,0 @@ -include requirements.txt README.md LICENSE.txt -recursive-include multipart *.py *.yaml *.bare *.http LICENSE*.* -recursive-exclude multipart *.pyc *.pyo *.pyd - diff --git a/multipart/__init__.py b/multipart/__init__.py index 309d698..b49d100 100644 --- a/multipart/__init__.py +++ b/multipart/__init__.py @@ -1,15 +1,15 @@ # This is the canonical package information. -__author__ = 'Andrew Dunham' -__license__ = 'Apache' +__author__ = "Andrew Dunham" +__license__ = "Apache" __copyright__ = "Copyright (c) 2012-2013, Andrew Dunham" -__version__ = "0.0.6" +__version__ = "0.0.6" from .multipart import ( FormParser, MultipartParser, - QuerystringParser, OctetStreamParser, + QuerystringParser, create_form_parser, parse_form, ) diff --git a/pyproject.toml b/pyproject.toml index 2220432..77deb1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,7 @@ description = "A streaming multipart parser for Python" readme = "README.rst" license = "Apache-2.0" requires-python = ">=3.7" -authors = [ - { name = "Andrew Dunham", email = "andrew@du.nham.ca" }, -] +authors = [{ name = "Andrew Dunham", email = "andrew@du.nham.ca" }] classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', @@ -56,10 +54,7 @@ Source = "https://github.com/andrew-d/python-multipart" path = "multipart/__init__.py" [tool.hatch.build.targets.wheel] -packages = [ - "multipart", -] +packages = ["multipart"] + [tool.hatch.build.targets.sdist] -include = [ - "/multipart", -] +include = ["/multipart", "/tests"] diff --git a/tasks.py b/tasks.py index 3ac7419..f2cec11 100644 --- a/tasks.py +++ b/tasks.py @@ -28,7 +28,7 @@ def test(ctx, all=False): test_cmd.append('-m "not slow_test"') # Test in this directory - test_cmd.append(os.path.join("multipart", "tests")) + test_cmd.append("tests") # Run the command. # TODO: why does this fail with pty=True? diff --git a/multipart/tests/__init__.py b/tests/__init__.py similarity index 100% rename from multipart/tests/__init__.py rename to tests/__init__.py diff --git a/multipart/tests/compat.py b/tests/compat.py similarity index 100% rename from multipart/tests/compat.py rename to tests/compat.py diff --git a/multipart/tests/test_data/http/CR_in_header.http b/tests/test_data/http/CR_in_header.http similarity index 100% rename from multipart/tests/test_data/http/CR_in_header.http rename to tests/test_data/http/CR_in_header.http diff --git a/multipart/tests/test_data/http/CR_in_header.yaml b/tests/test_data/http/CR_in_header.yaml similarity index 100% rename from multipart/tests/test_data/http/CR_in_header.yaml rename to tests/test_data/http/CR_in_header.yaml diff --git a/multipart/tests/test_data/http/CR_in_header_value.http b/tests/test_data/http/CR_in_header_value.http similarity index 100% rename from multipart/tests/test_data/http/CR_in_header_value.http rename to tests/test_data/http/CR_in_header_value.http diff --git a/multipart/tests/test_data/http/CR_in_header_value.yaml b/tests/test_data/http/CR_in_header_value.yaml similarity index 100% rename from multipart/tests/test_data/http/CR_in_header_value.yaml rename to tests/test_data/http/CR_in_header_value.yaml diff --git a/multipart/tests/test_data/http/almost_match_boundary.http b/tests/test_data/http/almost_match_boundary.http similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary.http rename to tests/test_data/http/almost_match_boundary.http diff --git a/multipart/tests/test_data/http/almost_match_boundary.yaml b/tests/test_data/http/almost_match_boundary.yaml similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary.yaml rename to tests/test_data/http/almost_match_boundary.yaml diff --git a/multipart/tests/test_data/http/almost_match_boundary_without_CR.http b/tests/test_data/http/almost_match_boundary_without_CR.http similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary_without_CR.http rename to tests/test_data/http/almost_match_boundary_without_CR.http diff --git a/multipart/tests/test_data/http/almost_match_boundary_without_CR.yaml b/tests/test_data/http/almost_match_boundary_without_CR.yaml similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary_without_CR.yaml rename to tests/test_data/http/almost_match_boundary_without_CR.yaml diff --git a/multipart/tests/test_data/http/almost_match_boundary_without_LF.http b/tests/test_data/http/almost_match_boundary_without_LF.http similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary_without_LF.http rename to tests/test_data/http/almost_match_boundary_without_LF.http diff --git a/multipart/tests/test_data/http/almost_match_boundary_without_LF.yaml b/tests/test_data/http/almost_match_boundary_without_LF.yaml similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary_without_LF.yaml rename to tests/test_data/http/almost_match_boundary_without_LF.yaml diff --git a/multipart/tests/test_data/http/almost_match_boundary_without_final_hyphen.http b/tests/test_data/http/almost_match_boundary_without_final_hyphen.http similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary_without_final_hyphen.http rename to tests/test_data/http/almost_match_boundary_without_final_hyphen.http diff --git a/multipart/tests/test_data/http/almost_match_boundary_without_final_hyphen.yaml b/tests/test_data/http/almost_match_boundary_without_final_hyphen.yaml similarity index 100% rename from multipart/tests/test_data/http/almost_match_boundary_without_final_hyphen.yaml rename to tests/test_data/http/almost_match_boundary_without_final_hyphen.yaml diff --git a/multipart/tests/test_data/http/bad_end_of_headers.http b/tests/test_data/http/bad_end_of_headers.http similarity index 100% rename from multipart/tests/test_data/http/bad_end_of_headers.http rename to tests/test_data/http/bad_end_of_headers.http diff --git a/multipart/tests/test_data/http/bad_end_of_headers.yaml b/tests/test_data/http/bad_end_of_headers.yaml similarity index 100% rename from multipart/tests/test_data/http/bad_end_of_headers.yaml rename to tests/test_data/http/bad_end_of_headers.yaml diff --git a/multipart/tests/test_data/http/bad_header_char.http b/tests/test_data/http/bad_header_char.http similarity index 100% rename from multipart/tests/test_data/http/bad_header_char.http rename to tests/test_data/http/bad_header_char.http diff --git a/multipart/tests/test_data/http/bad_header_char.yaml b/tests/test_data/http/bad_header_char.yaml similarity index 100% rename from multipart/tests/test_data/http/bad_header_char.yaml rename to tests/test_data/http/bad_header_char.yaml diff --git a/multipart/tests/test_data/http/bad_initial_boundary.http b/tests/test_data/http/bad_initial_boundary.http similarity index 100% rename from multipart/tests/test_data/http/bad_initial_boundary.http rename to tests/test_data/http/bad_initial_boundary.http diff --git a/multipart/tests/test_data/http/bad_initial_boundary.yaml b/tests/test_data/http/bad_initial_boundary.yaml similarity index 100% rename from multipart/tests/test_data/http/bad_initial_boundary.yaml rename to tests/test_data/http/bad_initial_boundary.yaml diff --git a/multipart/tests/test_data/http/base64_encoding.http b/tests/test_data/http/base64_encoding.http similarity index 100% rename from multipart/tests/test_data/http/base64_encoding.http rename to tests/test_data/http/base64_encoding.http diff --git a/multipart/tests/test_data/http/base64_encoding.yaml b/tests/test_data/http/base64_encoding.yaml similarity index 100% rename from multipart/tests/test_data/http/base64_encoding.yaml rename to tests/test_data/http/base64_encoding.yaml diff --git a/multipart/tests/test_data/http/empty_header.http b/tests/test_data/http/empty_header.http similarity index 100% rename from multipart/tests/test_data/http/empty_header.http rename to tests/test_data/http/empty_header.http diff --git a/multipart/tests/test_data/http/empty_header.yaml b/tests/test_data/http/empty_header.yaml similarity index 100% rename from multipart/tests/test_data/http/empty_header.yaml rename to tests/test_data/http/empty_header.yaml diff --git a/multipart/tests/test_data/http/multiple_fields.http b/tests/test_data/http/multiple_fields.http similarity index 100% rename from multipart/tests/test_data/http/multiple_fields.http rename to tests/test_data/http/multiple_fields.http diff --git a/multipart/tests/test_data/http/multiple_fields.yaml b/tests/test_data/http/multiple_fields.yaml similarity index 100% rename from multipart/tests/test_data/http/multiple_fields.yaml rename to tests/test_data/http/multiple_fields.yaml diff --git a/multipart/tests/test_data/http/multiple_files.http b/tests/test_data/http/multiple_files.http similarity index 100% rename from multipart/tests/test_data/http/multiple_files.http rename to tests/test_data/http/multiple_files.http diff --git a/multipart/tests/test_data/http/multiple_files.yaml b/tests/test_data/http/multiple_files.yaml similarity index 100% rename from multipart/tests/test_data/http/multiple_files.yaml rename to tests/test_data/http/multiple_files.yaml diff --git a/multipart/tests/test_data/http/quoted_printable_encoding.http b/tests/test_data/http/quoted_printable_encoding.http similarity index 100% rename from multipart/tests/test_data/http/quoted_printable_encoding.http rename to tests/test_data/http/quoted_printable_encoding.http diff --git a/multipart/tests/test_data/http/quoted_printable_encoding.yaml b/tests/test_data/http/quoted_printable_encoding.yaml similarity index 100% rename from multipart/tests/test_data/http/quoted_printable_encoding.yaml rename to tests/test_data/http/quoted_printable_encoding.yaml diff --git a/multipart/tests/test_data/http/single_field.http b/tests/test_data/http/single_field.http similarity index 100% rename from multipart/tests/test_data/http/single_field.http rename to tests/test_data/http/single_field.http diff --git a/multipart/tests/test_data/http/single_field.yaml b/tests/test_data/http/single_field.yaml similarity index 100% rename from multipart/tests/test_data/http/single_field.yaml rename to tests/test_data/http/single_field.yaml diff --git a/multipart/tests/test_data/http/single_field_blocks.http b/tests/test_data/http/single_field_blocks.http similarity index 100% rename from multipart/tests/test_data/http/single_field_blocks.http rename to tests/test_data/http/single_field_blocks.http diff --git a/multipart/tests/test_data/http/single_field_blocks.yaml b/tests/test_data/http/single_field_blocks.yaml similarity index 100% rename from multipart/tests/test_data/http/single_field_blocks.yaml rename to tests/test_data/http/single_field_blocks.yaml diff --git a/multipart/tests/test_data/http/single_field_longer.http b/tests/test_data/http/single_field_longer.http similarity index 100% rename from multipart/tests/test_data/http/single_field_longer.http rename to tests/test_data/http/single_field_longer.http diff --git a/multipart/tests/test_data/http/single_field_longer.yaml b/tests/test_data/http/single_field_longer.yaml similarity index 100% rename from multipart/tests/test_data/http/single_field_longer.yaml rename to tests/test_data/http/single_field_longer.yaml diff --git a/multipart/tests/test_data/http/single_field_single_file.http b/tests/test_data/http/single_field_single_file.http similarity index 100% rename from multipart/tests/test_data/http/single_field_single_file.http rename to tests/test_data/http/single_field_single_file.http diff --git a/multipart/tests/test_data/http/single_field_single_file.yaml b/tests/test_data/http/single_field_single_file.yaml similarity index 100% rename from multipart/tests/test_data/http/single_field_single_file.yaml rename to tests/test_data/http/single_field_single_file.yaml diff --git a/multipart/tests/test_data/http/single_field_with_leading_newlines.http b/tests/test_data/http/single_field_with_leading_newlines.http similarity index 100% rename from multipart/tests/test_data/http/single_field_with_leading_newlines.http rename to tests/test_data/http/single_field_with_leading_newlines.http diff --git a/multipart/tests/test_data/http/single_field_with_leading_newlines.yaml b/tests/test_data/http/single_field_with_leading_newlines.yaml similarity index 100% rename from multipart/tests/test_data/http/single_field_with_leading_newlines.yaml rename to tests/test_data/http/single_field_with_leading_newlines.yaml diff --git a/multipart/tests/test_data/http/single_file.http b/tests/test_data/http/single_file.http similarity index 100% rename from multipart/tests/test_data/http/single_file.http rename to tests/test_data/http/single_file.http diff --git a/multipart/tests/test_data/http/single_file.yaml b/tests/test_data/http/single_file.yaml similarity index 100% rename from multipart/tests/test_data/http/single_file.yaml rename to tests/test_data/http/single_file.yaml diff --git a/multipart/tests/test_data/http/utf8_filename.http b/tests/test_data/http/utf8_filename.http similarity index 100% rename from multipart/tests/test_data/http/utf8_filename.http rename to tests/test_data/http/utf8_filename.http diff --git a/multipart/tests/test_data/http/utf8_filename.yaml b/tests/test_data/http/utf8_filename.yaml similarity index 100% rename from multipart/tests/test_data/http/utf8_filename.yaml rename to tests/test_data/http/utf8_filename.yaml diff --git a/multipart/tests/test_multipart.py b/tests/test_multipart.py similarity index 99% rename from multipart/tests/test_multipart.py rename to tests/test_multipart.py index 089f451..031515b 100644 --- a/multipart/tests/test_multipart.py +++ b/tests/test_multipart.py @@ -1,8 +1,6 @@ import os import sys -import glob import yaml -import base64 import random import tempfile import unittest @@ -12,9 +10,9 @@ slow_test, ) from io import BytesIO -from unittest.mock import MagicMock, Mock, patch +from unittest.mock import Mock -from ..multipart import * +from multipart.multipart import * # Get the current directory for our later test cases. diff --git a/tox.ini b/tox.ini index 85d1b54..16f7b05 100644 --- a/tox.ini +++ b/tox.ini @@ -8,4 +8,4 @@ deps= pytest-timeout PyYAML commands= - pytest --cov-report term-missing --cov-config .coveragerc --cov multipart --timeout=30 multipart/tests + pytest --cov-report term-missing --cov-config .coveragerc --cov multipart --timeout=30 tests