Edgewall Software
Modify

Opened 18 years ago

Closed 16 years ago

#3858 closed defect (fixed)

mimeview unit test fails

Reported by: david.vanmaren@… Owned by: Christian Boos
Priority: low Milestone: 0.11
Component: general Version: 0.10
Severity: minor Keywords: mimeview
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

This is likely related to #3332, but when I run the unit tests on 0.10, I get a failed assertion.

From my uninformed perspective, it appears that the defect is in the test code, rather than in the logic of get_mimetype().

I am running SLES10, x86_64, Python 2.4.2. Here's a snippet of svn info from my working copy:

URL: http://svn.edgewall.com/repos/trac/tags/trac-0.10
Revision: 3804

Here's the test output:

$ PYTHONPATH=. trac/test.py
SKIP: mimeview/tests/php.py
.................................................................F............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
======================================================================
FAIL: test_from_suffix_using_mimetypes (trac.mimeview.tests.api.GetMimeTypeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/trac-svn/trac/mimeview/tests/api.py", line 26, in test_from_suffix_using_mimetypes
    get_mimetype('test.pyc', None))
AssertionError: 'application/x-python-code' != 'application/x-python-bytecode'

----------------------------------------------------------------------
Ran 590 tests in 39.788s

FAILED (failures=1)

Attachments (0)

Change History (4)

comment:1 by Christian Boos, 18 years ago

Milestone: 0.10.1
Owner: changed from Jonas Borgström to Christian Boos

Well, I guess it's a problem with Python's mimetypes module.

Mine gives:

$ python
ActivePython 2.4.2 Build 248 (ActiveState Corp.) based on
Python 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import mimetypes
>>> mimetypes.init()
>>> mimetypes.types_map['.pyc']
'application/x-python-code'
>>>

I guess we should pick a test case less susceptible to differ from platform to platform or version to version…

comment:2 by osimons, 16 years ago

Well, there are some other types available that should be quite standard. How about:

  • trac/mimeview/tests/api.py

     
    2525        self.assertEqual('text/plain', get_mimetype('README.txt', None))
    2626       
    2727    def test_from_suffix_using_mimetypes(self):
    28         self.assertEqual('application/x-python-code',
    29                          get_mimetype('test.pyc', None))
     28        self.assertEqual('image/png',
     29                         get_mimetype('doc/trac_logo.png', None))
    3030       
    3131    def test_from_content_using_CONTENT_RE(self):
    3232        self.assertEqual('text/x-python',

comment:3 by Christian Boos, 16 years ago

Milestone: 0.10.50.11

Please do ;-) (not worth doing for 0.10.x though)

comment:4 by osimons, 16 years ago

Resolution: fixed
Status: newclosed

Oki. Done in [6470]. Closing.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.