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

Suppress deprecation warnings in tests (except cgi) #93

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
*.log
*.pyc
.tox

.coverage
.idea
.pytest_cache
.tox
.venv
.vscode

*.egg-info

build
dist
docs/_build/
11 changes: 8 additions & 3 deletions paste/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

import warnings

try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
import pkg_resources
pkg_resources.declare_namespace(__name__)
except (AttributeError, ImportError):
# don't prevent use of paste if pkg_resources isn't installed
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
Expand Down
18 changes: 11 additions & 7 deletions paste/urlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@

import os
import sys
import importlib.util as imputil

import mimetypes
import warnings
import importlib.util as imputil
try:
import pkg_resources
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
import pkg_resources
except ImportError:
pkg_resources = None
from paste import request
from paste import fileapp
from paste.util import import_string
from paste import httpexceptions
from .httpheaders import ETAG
from paste.util import converters
from .httpheaders import ETAG

class NoDefault(object):
__all__ = ['URLParser', 'StaticURLParser', 'PkgResourcesParser']


class NoDefault:
pass

__all__ = ['URLParser', 'StaticURLParser', 'PkgResourcesParser']

class URLParser(object):
class URLParser:

"""
WSGI middleware
Expand Down
8 changes: 1 addition & 7 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import sys
import os

sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))

import pkg_resources
pkg_resources.require('Paste')
"""Tests for Paste"""
7 changes: 5 additions & 2 deletions tests/test_recursive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .test_errordocument import simple_app
import pytest
from paste.fixture import TestApp
from paste.recursive import RecursiveMiddleware, ForwardRequestException
from .test_errordocument import simple_app

def error_docs_app(environ, start_response):
if environ['PATH_INFO'] == '/not_found':
Expand Down Expand Up @@ -102,4 +103,6 @@ def __call__(self, environ, start_response):
if environ['PATH_INFO'] != '/not_found':
return self.app(environ, start_response)
raise ForwardRequestException(path_info=self.url)
forward(TestForwardRequestExceptionMiddleware(error_docs_app))

with pytest.warns(DeprecationWarning):
forward(TestForwardRequestExceptionMiddleware(error_docs_app))
8 changes: 6 additions & 2 deletions tests/test_urlparser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os
import warnings

with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
from pkg_resources import get_distribution

from paste.urlparser import PkgResourcesParser, StaticURLParser, URLParser
from paste.fixture import TestApp
from pkg_resources import get_distribution
from paste.urlparser import PkgResourcesParser, StaticURLParser, URLParser

def relative_path(name):
here = os.path.join(os.path.dirname(os.path.abspath(__file__)),
Expand Down
Loading