コード例 #1
0
ファイル: test_manifest.py プロジェクト: pferreir/pywebpack
def test_render():
    """Test rendering."""
    m = Manifest()
    m.add(ManifestEntry('script', ['/a.js', '/b.js']))
    m.add(ManifestEntry('styles', ['/a.css', '/b.css']))

    assert m.script.render() == m['script'].render() == str(m.script) == \
        '<script src="/a.js"></script>' \
        '<script src="/b.js"></script>'
    assert m.styles.render() == m['styles'].render() == \
        '<link rel="stylesheet" href="/a.css"></link>' \
        '<link rel="stylesheet" href="/b.css"></link>'
コード例 #2
0
def test_invalid_ext():
    """Test invalid entry ext."""
    m = Manifest()
    m.add(ManifestEntry('script', ['/a.exe']))
    pytest.raises(UnsupportedExtensionError, m.script.render)
コード例 #3
0
def test_nonexisting_entry():
    """Test non-existing entry."""
    m = Manifest()
    pytest.raises(AttributeError, getattr, m, 'script')
    pytest.raises(KeyError, m.__getitem__, 'script')
コード例 #4
0
def test_manifest_add_same_name():
    """Test add with same name."""
    m = Manifest()
    m.add(ManifestEntry('script', ['/a.js']))
    pytest.raises(KeyError, m.add, ManifestEntry('script', ['/b.js']))
コード例 #5
0
def exmanif():
    m = Manifest()
    m.add(ManifestEntry('script', ['/a.js', '/b.js']))
    m.add(ManifestEntry('styles', ['/a.css', '/b.css']))
    return m