Edgewall Software
Modify

Ticket #3858 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years 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:
Release Notes:
API 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

Change History

comment:1 Changed 5 years ago by cboos

  • Milestone set to 0.10.1
  • Owner changed from jonas to cboos

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 Changed 4 years 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', 

comment:3 Changed 4 years ago by cboos

  • Milestone changed from 0.10.5 to 0.11

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

comment:4 Changed 4 years ago by osimons

  • Resolution set to fixed
  • Status changed from new to closed

Oki. Done in [6470]. Closing.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from cboos. Next status will be 'closed'
Author


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

 
Note: See TracTickets for help on using tickets.