Modify

Opened 7 years ago

Closed 12 months ago

#13066 closed defect (wontfix)

Test failures

Reported by: Ryan J Ollos Owned by:
Priority: normal Component: XmlRpcPlugin
Severity: normal Keywords:
Cc: Olemis Lang, osimons Trac Release:

Description

Running tests on 1.0-stable with OSX results in one failure:

======================================================================
FAIL: test_xml_encoding_special_characters (tracrpc.tests.xml_rpc.RpcXmlTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/xmlrpcplugin/tracrpc/tests/xml_rpc.py", line 113, in test_xml_encoding_special_characters
    ticket[3]['description'])
AssertionError: 'Desc & ription\r\nLine 2' != 'Desc & ription\nLine 2'

----------------------------------------------------------------------

With Trac 1.2-stable, two additional failures:

======================================================================
FAIL: test_xml_encoding_special_characters (tracrpc.tests.xml_rpc.RpcXmlTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/xmlrpcplugin/tracrpc/tests/xml_rpc.py", line 113, in test_xml_encoding_special_characters
    ticket[3]['description'])
AssertionError: 'Desc & ription\r\nLine 2' != 'Desc & ription\nLine 2'

======================================================================
FAIL: test_getActions (tracrpc.tests.ticket.RpcTicketTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/xmlrpcplugin/tracrpc/tests/ticket.py", line 73, in test_getActions
    self.assertEquals(actions, default)
AssertionError: Lists differ: [['leave', 'leave', 'The owner... != [['leave', 'leave', 'The ticke...

First differing element 0:
['leave', 'leave', 'The owner will remain <span class="trac-author">&lt; default &gt;</span>.', []]
['leave', 'leave', 'The ticket will remain with no owner.', []]

Diff is 1304 characters long. Set self.maxDiff to None to see it.

======================================================================
FAIL: test_update_action (tracrpc.tests.ticket.RpcTicketTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/xmlrpcplugin/tracrpc/tests/ticket.py", line 335, in test_update_action
    self.assertEqual('', current[3].get('owner', ''))
AssertionError: '' != '< default >'

----------------------------------------------------------------------

The two failures on 1.2-stable look like changes I'm familiar with from Trac 1.2, so not unexpected.

Attachments (2)

t13066.diff (2.3 KB) - added by Ryan J Ollos 7 years ago.
t13066-use-jsonrpc-r18229.diff (2.6 KB) - added by Jun Omae 3 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 7 years ago by Ryan J Ollos

Owner: changed from osimons to Ryan J Ollos
Status: newaccepted

Changed 7 years ago by Ryan J Ollos

Attachment: t13066.diff added

comment:2 Changed 7 years ago by Ryan J Ollos

Cc: osimons added

Any idea about this failure? I see it on OSX with Trac 1.0 as well.

======================================================================
FAIL: test_xml_encoding_special_characters (tracrpc.tests.xml_rpc.RpcXmlTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/trac-hacks/xmlrpcplugin/trunk/tracrpc/tests/xml_rpc.py", line 113, in test_xml_encoding_special_characters
    ticket[3]['description'])
AssertionError: 'Desc & ription\r\nLine 2' != 'Desc & ription\nLine 2'

----------------------------------------------------------------------
Ran 58 tests in 66.747s

FAILED (failures=1)
Test failed: <unittest.runner.TextTestResult run=58 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=58 errors=0 failures=1>

Other proposed changes in attachment:t13066.diff. Tests pass for me with Trac 1.0 and 1.2-stable.

comment:3 Changed 7 years ago by osimons

For \r\n vs \n background see #2482. I noticed it recently but have not researched the cause.

As for proposed changes in attachment I can't remember the details of styling anymore, but as this is just changes to tests I trust that my 0.12.x testing won't break later ;-)

comment:4 Changed 7 years ago by Ryan J Ollos

The response sent in xmlrpcplugin/trunk/tracrpc/xml_rpc.py@13776:177#L169 contains the \r\n. I ran tests r13776 and 1.0-stable and the failure is seen. Any ideas where to look next?

comment:5 Changed 7 years ago by Ryan J Ollos

Probably unrelated to the comment:2 issue, but on 1.2-stable the following is output at the end of the test run:

Test failed: <unittest.runner.TextTestResult run=58 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=58 errors=0 failures=1>
/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/util/__init__.py:413: RuntimeWarning: Parent module 'trac.util' not found while handling absolute import
  import signal

The RuntimeWarning isn't seen if I move import signal to module scope: trac:browser:branches/1.2-stable/trac/util/__init__.py@15609:413#L392.

comment:6 Changed 7 years ago by Ryan J Ollos

In 16279:

XmlRpcPlugin 1.1.6: Fix test failures with Trac 1.2-stable

Refs #13066.

comment:7 Changed 7 years ago by Ryan J Ollos

Owner: Ryan J Ollos deleted
Status: acceptednew

Remaining issue to be fixed is test failure shown in comment:1.

Changed 3 years ago by Jun Omae

comment:8 Changed 3 years ago by Jun Omae

The test case creates a ticket with \r\n confirmed by debug logging.

2021-04-17 12:13:48,308 Trac[xml_rpc] DEBUG: RPC(xml) 'ticket.get' result:
 [1, datetime.datetime(2021, 4, 17, 3, 13, 48, 292507, tzinfo=<FixedOffset "UTC" 0:00:00>),
 datetime.datetime(2021, 4, 17, 3, 13, 48, 292507, tzinfo=<FixedOffset "UTC" 0:00:00>),
 {'status': u'new', 'changetime': datetime.datetime(2021, 4, 17, 3, 13, 48, 292507,
 tzinfo=<FixedOffset "UTC" 0:00:00>), '_ts': '1618629228292507',
 'description': u'Desc & ription\r\nLine 2', 'reporter': u'admin', 'cc': u'', 'resolution': u'',
 'time': datetime.datetime(2021, 4, 17, 3, 13, 48, 292507, tzinfo=<FixedOffset "UTC" 0:00:00>),
 'component': u'', 'summary': u'One & Two < Four', 'priority': u'major', 'keywords': u'',
 'version': u'', 'milestone': u'', 'owner': u'< default >', 'type': u'defect'}]

However, xmlrpclib.loads() normalizes \r\n and \n to \n.

>>> data = ('aaa\r\nbbb\r\n', 'ccc\nddd\n')
>>> xmlrpclib.dumps(data)
'<params>\n<param>\n<value><string>aaa\r\nbbb\r\n</string></value>\n</param>\n<param>\n<value><string>ccc\nddd\n</string></value>\n</param>\n</params>\n'
>>> xmlrpclib.loads(xmlrpclib.dumps(data))
(('aaa\nbbb\n', 'ccc\nddd\n'), None)

Therefore, ticket.get via xmlrpc is unable to verify the ticket description has \r\n. Instead, I think we could use jsonrpc to verify the ticket.

Proposed changes in attachment:t13066-use-jsonrpc-r18229.diff.

comment:9 Changed 12 months ago by Jun Omae

The test_xml_encoding_special_characters is marked as XFAIL with unittest.expectedFailure, because newlines are normalized to \n in xmlrpc.

comment:10 Changed 12 months ago by Jun Omae

Resolution: wontfix
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.