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

Remove slow_test pytest marker #120

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ packages = ["multipart"]
[tool.hatch.build.targets.sdist]
include = ["/multipart", "/tests"]

[tool.pytest.ini_options]
markers = [
"slow_test: marks tests as slow (deselect with '-m \"not slow_test\"')",
]

[tool.ruff]
line-length = 120

Expand Down
23 changes: 0 additions & 23 deletions tests/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,6 @@ def _samefile(x, y):
sys.path.insert(0, path)


# Check if pytest is imported. If so, we use it to create marking decorators.
# If not, we just create a function that does nothing.
try:
import pytest
except ImportError:
pytest = None

if pytest is not None:
slow_test = pytest.mark.slow_test
xfail = pytest.mark.xfail

else:

def slow_test(x):
return x

def xfail(*args, **kwargs):
if len(args) > 0 and isinstance(args[0], types.FunctionType):
return args[0]

return lambda x: x


# We don't use the pytest parametrizing function, since it seems to break
# with unittest.TestCase subclasses.
def parametrize(field_names, field_values):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from unittest.mock import Mock

import yaml
from pytest import mark
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use import purest please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


from multipart.decoders import Base64Decoder, QuotedPrintableDecoder
from multipart.exceptions import DecodeError, FileError, FormParserError, MultipartParseError
Expand All @@ -27,7 +28,7 @@
parse_options_header,
)

from .compat import parametrize, parametrize_class, slow_test
from .compat import parametrize, parametrize_class

if TYPE_CHECKING:
from multipart.multipart import FileConfig
Expand Down Expand Up @@ -905,7 +906,7 @@ def test_feed_blocks(self):
# Assert that our field is here.
self.assert_field(b"field", b"0123456789ABCDEFGHIJ0123456789ABCDEFGHIJ")

@slow_test
@mark.slow_test
def test_request_body_fuzz(self):
"""
This test randomly fuzzes the request body to ensure that no strange
Expand Down Expand Up @@ -978,7 +979,7 @@ def test_request_body_fuzz(self):
print("Failures: %d" % (failures,))
print("Exceptions: %d" % (exceptions,))

@slow_test
@mark.slow_test
def test_request_body_fuzz_random_data(self):
"""
This test will fuzz the multipart parser with some number of iterations
Expand Down