Edgewall Software

Ticket #3858 (closed defect: fixed)

Opened 2 years ago

Last modified 10 months ago

mimeview unit test fails

Reported by: david.vanmaren@… Owned by: cboos
Priority: low Milestone: 0.11
Component: general Version: 0.10
Severity: minor Keywords: mimeview
Cc:

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

Change History

Changed 2 years ago by cboos

  • owner changed from jonas to cboos
  • milestone set to 0.10.1

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...

Changed 10 months ago by osimons

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', 

Changed 10 months ago by cboos

  • milestone changed from 0.10.5 to 0.11

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

Changed 10 months ago by osimons

  • status changed from new to closed
  • resolution set to fixed

Oki. Done in [6470]. Closing.

Add/Change #3858 (mimeview unit test fails)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.