Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

67 lines (49 sloc) 1.77 KB
# -*- coding: utf8 -*-
import os
import tempfile
from zipfile import BadZipfile, ZipFile
from import eq_
from validator.xpi import XPIManager
RESOURCES_PATH = os.path.join(os.path.dirname(__file__), 'resources')
def get_path(fn):
return os.path.join(RESOURCES_PATH, fn)
def test_open():
"""Test that the manager will open the package."""
z = XPIManager(get_path('xpi/install_rdf_only.xpi'))
assert z is not None
def test_get_list():
"""Test that the manager can read the file listing."""
z = XPIManager(get_path('xpi/install_rdf_only.xpi'))
assert not z.contents_cache
assert z.package_contents()
assert z.contents_cache # Spelling check!
z.contents_cache = 'foo'
eq_(z.package_contents(), 'foo')
def test_valid_name():
"Test that the manager can retrieve the correct file name."
z = XPIManager(get_path('xpi/install_rdf_only.xpi'))
contents = z.package_contents()
assert 'install.rdf' in contents
def test_read_file():
"""Test that a file can be read from the package."""
z = XPIManager(get_path('xpi/install_rdf_only.xpi'))
assert'install.rdf') is not None
def test_write_file():
"""Test that a file can be written in UTF-8 to the package."""
with tempfile.NamedTemporaryFile(delete=False) as t:
temp_fn =
z = XPIManager(temp_fn, mode='w')
f, d = 'install.rdf', '注目のコレクション'.decode('utf-8')
z.write(f, d)
eq_(, d.encode('utf-8'))
def test_missing_file():
"""Tests that the XPI manager correctly reports a missing XPI file."""
passed = False
x = XPIManager('')
passed = True
assert passed
Jump to Line
Something went wrong with that request. Please try again.