From c34a10d8b7bcf00998d556ed3f9b5474aacad3a0 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 30 Apr 2024 09:21:56 +0100 Subject: [PATCH 1/3] Cleanup namespace handling in tests When we did a lot of recent Python2-isms cleanup recently it broke some tests when run in an environment where a previous version of paste, or one of the consumers of its namespace package, were already installed. This was probably done to quiet warnings. However, it hides issues with complex environments. In addition to fixing the problem, this change adds a tox test environment that should cause a failure if we introduce the error again. Fixes #99 --- .github/workflows/tests.yaml | 2 ++ tests/__init__.py | 6 ++++++ tests/cgiapp_data/form.cgi | 11 ++++++++++- tox.ini | 21 ++++++++++++++++++--- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ac3ceff..c72b6ca 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,6 +17,8 @@ jobs: env: py310 - python: "3.11" env: py311 + - python: "3.11" + env: py311-namespace - python: "3.12" env: py312 - python: pypy-3.10 diff --git a/tests/__init__.py b/tests/__init__.py index cafcf8a..2f10103 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1,7 @@ """Tests for Paste""" +import sys +import os + +sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + +import pkg_resources diff --git a/tests/cgiapp_data/form.cgi b/tests/cgiapp_data/form.cgi index e751aa0..21dca13 100755 --- a/tests/cgiapp_data/form.cgi +++ b/tests/cgiapp_data/form.cgi @@ -4,11 +4,20 @@ print('Content-type: text/plain') print('') import sys +import warnings from os.path import dirname base_dir = dirname(dirname(dirname(__file__))) sys.path.insert(0, base_dir) +with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=DeprecationWarning) + try: + import pkg_resources + except ImportError: + # Ignore + pass + from paste.util.field_storage import FieldStorage class FormFieldStorage(FieldStorage): @@ -52,7 +61,7 @@ class FormFieldStorage(FieldStorage): return False -form = FieldStorage() +form = FormFieldStorage() print('Filename:', form['up'].filename) print('Name:', form['name'].value) diff --git a/tox.ini b/tox.ini index f58ba41..12ce052 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,29 @@ [tox] -envlist = py{36, 37, 38, 39, 310, 311, 312, py} +envlist = py{36, 37, 38, 39, 310, 311, 312, py},py311-namespace +skipsdist = True + +[base] +deps = + pytest + setuptools [testenv] # For performance, but also for using "source" with coveragepy (https://github.com/nedbat/coveragepy/issues/268). usedevelop = True deps = - pytest + {[base]deps} coverage: coverage coverage: pytest-cov setenv = coverage: PYTEST_ADDOPTS=--cov --cov-report=term-missing commands = - pytest {posargs} + python -m pytest {posargs} + +# Test an environment where paste, pastedeploy and pastescript are already +# installed. +[testenv:py311-namespace] +deps = + {[base]deps} + Paste==3.9.0 + PasteDeploy + pastescript From 129a76e7201760924f1afe60bff1b7208f66db52 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 30 Apr 2024 09:36:33 +0100 Subject: [PATCH 2/3] remove skipsdist to see if that ensures namespace --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 12ce052..f6159ad 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,5 @@ [tox] envlist = py{36, 37, 38, 39, 310, 311, 312, py},py311-namespace -skipsdist = True [base] deps = From b211da9b985fe1cf097a9faa71f1ccac4ceaacdf Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 30 Apr 2024 10:39:54 +0100 Subject: [PATCH 3/3] update LICENSE per #101 --- LICENSE | 1 + MANIFEST.in | 1 + 2 files changed, 2 insertions(+) create mode 120000 LICENSE diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..7ca850b --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +docs/license.txt \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index cc3f4ba..996cd67 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,7 @@ include docs/conf.py include docs/test_server.ini include regen-docs include tox.ini +include LICENSE recursive-exclude docs/_build/_sources * recursive-include docs/_build *.html recursive-include tests *.txt *.py *.cgi *.html