Edgewall Software
Modify

Opened 4 weeks ago

Closed 3 weeks ago

#13788 closed defect (fixed)

Unit tests failing with multipart 1.0.0

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.6.1
Component: general Version: 1.6
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Adapted unit tests to multipart 1.0.0+.

API Changes:
Internal Changes:

Description

After multipart 1.0.0 is released on Sep 21, 2024, unit tests failed.

======================================================================
ERROR: test_getfile (trac.web.tests.api.RequestTestCase.test_getfile)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/web/tests/api.py", line 287, in test_getfile
    self.assertEqual(file_content, file_[1].getvalue())
                                   ^^^^^^^^^^^^^^^^^
AttributeError: 'SpooledTemporaryFile' object has no attribute 'getvalue'

======================================================================
ERROR: test_getfilelist (trac.web.tests.api.RequestTestCase.test_getfilelist)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/web/tests/api.py", line 330, in test_getfilelist
    self.assertEqual(file_content[0], file_[0][1].getvalue())
                                      ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SpooledTemporaryFile' object has no attribute 'getvalue'

======================================================================
FAIL: test_post_with_unnamed_value (trac.web.tests.api.RequestTestCase.test_post_with_unnamed_value)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/web/tests/api.py", line 560, in test_post_with_unnamed_value
    self.assertEqual('named value', req.args['foo'])
                                    ^^^^^^^^
  File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 689, in __getattr__
    value = self.callbacks[name](self)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 671, in <lambda>
    'args': lambda req: arg_list_to_args(req.arg_list),
                                         ^^^^^^^^^^^^
  File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 689, in __getattr__
    value = self.callbacks[name](self)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 1046, in _parse_arg_list
    return list(parse_form_data(self.environ))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jun66j5/src/tracdev/git/trac/web/api.py", line 535, in parse_form_data
    forms, files = multipart.parse_form_data(environ, charset='utf-8',
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jun66j5/venv/py312/lib/python3.12/site-packages/multipart.py", line 790, in parse_form_data
    for part in MultipartParser(stream, boundary, content_length, **kwargs):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jun66j5/venv/py312/lib/python3.12/site-packages/multipart.py", line 596, in __iter__
    for part in self._part_iter:
                ^^^^^^^^^^^^^^^
  File "/home/jun66j5/venv/py312/lib/python3.12/site-packages/multipart.py", line 634, in _iterparse
    for event in parser.parse(read(bufsize)):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jun66j5/venv/py312/lib/python3.12/site-packages/multipart.py", line 347, in parse
    self._current._update_size(index - offset)
  File "/home/jun66j5/venv/py312/lib/python3.12/site-packages/multipart.py", line 493, in _update_size
    assert self.name and not self.complete
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

----------------------------------------------------------------------
Ran 2806 tests in 33.783s

FAILED (failures=1, errors=2, skipped=5)

Attachments (0)

Change History (2)

comment:1 by Jun Omae, 4 weeks ago

I'm guessing to be a defect of multipart module. I've filed it at https://github.com/defnull/multipart/issues/56.

Also, I'll plan to add multipart!=1.0.0 because of no workaround….

  • setup.cfg

    diff --git a/setup.cfg b/setup.cfg
    index 7ff04ddfd..385c8e098 100644
    a b setup_requires =  
    3939install_requires =
    4040    setuptools>=30.3
    4141    jinja2>=2.9.3
    42     multipart; python_version>='3.13'
     42    multipart!=1.0.0; python_version>='3.13'
    4343
    4444[options.package_data]
    4545* = templates/*.*

comment:2 by Jun Omae, 3 weeks ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Fixed in [17854] and merged [17856].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.