Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_mimetypes.MimeTypesTestCase Class Reference

List of all members.

Public Member Functions

def setUp
def test_default_data
def test_data_urls
def test_file_parsing
def test_non_standard_types
def test_guess_all_types

Public Attributes

 db

Detailed Description

Definition at line 14 of file test_mimetypes.py.


Member Function Documentation

Definition at line 15 of file test_mimetypes.py.

00015 
00016     def setUp(self):
00017         self.db = mimetypes.MimeTypes()

Here is the caller graph for this function:

Definition at line 25 of file test_mimetypes.py.

00025 
00026     def test_data_urls(self):
00027         eq = self.assertEqual
00028         guess_type = self.db.guess_type
00029         eq(guess_type("data:,thisIsTextPlain"), ("text/plain", None))
00030         eq(guess_type("data:;base64,thisIsTextPlain"), ("text/plain", None))
00031         eq(guess_type("data:text/x-foo,thisIsTextXFoo"), ("text/x-foo", None))

Here is the call graph for this function:

Definition at line 18 of file test_mimetypes.py.

00018 
00019     def test_default_data(self):
00020         eq = self.assertEqual
00021         eq(self.db.guess_type("foo.html"), ("text/html", None))
00022         eq(self.db.guess_type("foo.tgz"), ("application/x-tar", "gzip"))
00023         eq(self.db.guess_type("foo.tar.gz"), ("application/x-tar", "gzip"))
00024         eq(self.db.guess_type("foo.tar.Z"), ("application/x-tar", "compress"))

Here is the call graph for this function:

Definition at line 32 of file test_mimetypes.py.

00032 
00033     def test_file_parsing(self):
00034         eq = self.assertEqual
00035         sio = io.StringIO("x-application/x-unittest pyunit\n")
00036         self.db.readfp(sio)
00037         eq(self.db.guess_type("foo.pyunit"),
00038            ("x-application/x-unittest", None))
00039         eq(self.db.guess_extension("x-application/x-unittest"), ".pyunit")

Here is the call graph for this function:

Definition at line 49 of file test_mimetypes.py.

00049 
00050     def test_guess_all_types(self):
00051         eq = self.assertEqual
00052         unless = self.assertTrue
00053         # First try strict.  Use a set here for testing the results because if
00054         # test_urllib2 is run before test_mimetypes, global state is modified
00055         # such that the 'all' set will have more items in it.
00056         all = set(self.db.guess_all_extensions('text/plain', strict=True))
00057         unless(all >= set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt']))
00058         # And now non-strict
00059         all = self.db.guess_all_extensions('image/jpg', strict=False)
00060         all.sort()
00061         eq(all, ['.jpg'])
00062         # And now for no hits
00063         all = self.db.guess_all_extensions('image/jpg', strict=True)
00064         eq(all, [])
00065 
00066 
@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")

Here is the call graph for this function:

Definition at line 40 of file test_mimetypes.py.

00040 
00041     def test_non_standard_types(self):
00042         eq = self.assertEqual
00043         # First try strict
00044         eq(self.db.guess_type('foo.xul', strict=True), (None, None))
00045         eq(self.db.guess_extension('image/jpg', strict=True), None)
00046         # And then non-strict
00047         eq(self.db.guess_type('foo.xul', strict=False), ('text/xul', None))
00048         eq(self.db.guess_extension('image/jpg', strict=False), '.jpg')

Here is the call graph for this function:


Member Data Documentation

Definition at line 16 of file test_mimetypes.py.


The documentation for this class was generated from the following file: