Beispiel #1
0
def test_closure_minifier_communicate_exit_status(tmpdir):
    compiler = fanstatic.MinifierRegistry.instance()['closure']
    if not compiler.available:
        pytest.skip('`%s` not found' % compiler.package)
    from fanstatic.compiler import CompilerError

    source = str(tmpdir / 'a.js')
    target = str(tmpdir / 'a.min.js')

    with pytest.raises(CompilerError) as exc:
        compiler.process(source, target)
    assert 'Cannot read:' in str(exc)
Beispiel #2
0
def test_cssmin_minifier(tmpdir):
    compiler = fanstatic.MinifierRegistry.instance()['cssmin']
    if not compiler.available:
        pytest.skip('`%s` not found' % compiler.package)

    source = str(tmpdir / 'a.scss')
    target = str(tmpdir / 'a.css')
    with open(source, 'w') as f:
        f.write('body { padding: 2px; }')
    compiler.process(source, target)

    assert 'body{padding:2px}' == open(target).read()
Beispiel #3
0
def test_closure_minifier(tmpdir):
    compiler = fanstatic.MinifierRegistry.instance()['closure']
    if not compiler.available:
        pytest.skip('`%s` not found' % compiler.package)

    source = str(tmpdir / 'a.js')
    target = str(tmpdir / 'a.min.js')
    with open(source, 'w') as f:
        f.write('function foo() { var bar = "baz"; };')
    compiler.process(source, target)

    assert 'function foo(){var bar="baz"};\n' == open(target).read()
Beispiel #4
0
def test_less_compiler(tmpdir):
    compiler = fanstatic.CompilerRegistry.instance()['less']
    if not compiler.available:
        pytest.skip('`%s` not found on PATH' % compiler.command)

    source = str(tmpdir / 'a.less')
    target = str(tmpdir / 'a.css')
    with open(source, 'w') as f:
        f.write('body { padding: (1 + 1)px; }')
    compiler.process(source, target)

    assert 'padding: 2 px;' in open(target).read()
def test_closure_minifier_communicate_exit_status(tmpdir):
    compiler = fanstatic.MinifierRegistry.instance()['closure']
    if not compiler.available:
        pytest.skip('`%s` not found' % compiler.package)
    from fanstatic.compiler import CompilerError

    source = str(tmpdir / 'a.js')
    target = str(tmpdir / 'a.min.js')

    with pytest.raises(CompilerError) as exc:
        compiler.process(source, target)
    assert 'Cannot read' in str(exc)
Beispiel #6
0
def test_coffeescript_compiler(tmpdir):
    compiler = fanstatic.CompilerRegistry.instance()['coffee']
    if not compiler.available:
        pytest.skip('`%s` not found on PATH' % compiler.command)

    source = str(tmpdir / 'a.coffee')
    target = str(tmpdir / 'a.js')
    with open(source, 'w') as f:
        f.write('square = (x) -> x * x')
    compiler.process(source, target)

    assert 'square = function(x) {' in open(target).read()
def test_closure_minifier(tmpdir):
    compiler = fanstatic.MinifierRegistry.instance()['closure']
    if not compiler.available:
        pytest.skip('`%s` not found' % compiler.package)

    source = str(tmpdir / 'a.js')
    target = str(tmpdir / 'a.min.js')
    with open(source, 'w') as f:
        f.write('function foo() { var bar = "baz"; };')
    compiler.process(source, target)

    assert 'function foo(){var bar="baz"};\n' == open(target).read()
def test_cssmin_minifier(tmpdir):
    compiler = fanstatic.MinifierRegistry.instance()['cssmin']
    if not compiler.available:
        pytest.skip('`%s` not found' % compiler.package)

    source = str(tmpdir / 'a.scss')
    target = str(tmpdir / 'a.css')
    with open(source, 'w') as f:
        f.write('body { padding: 2px; }')
    compiler.process(source, target)

    assert 'body{padding:2px}' == open(target).read()
def test_less_compiler(tmpdir):
    compiler = fanstatic.CompilerRegistry.instance()['less']
    if not compiler.available:
        pytest.skip('`%s` not found on PATH' % compiler.command)

    source = str(tmpdir / 'a.less')
    target = str(tmpdir / 'a.css')
    with open(source, 'w') as f:
        f.write('body { padding: (1 + 1)px; }')
    compiler.process(source, target)

    assert 'padding: 2 px;' in open(target).read()
def test_coffeescript_compiler(tmpdir):
    compiler = fanstatic.CompilerRegistry.instance()['coffee']
    if not compiler.available:
        pytest.skip('`%s` not found on PATH' % compiler.command)

    source = str(tmpdir / 'a.coffee')
    target = str(tmpdir / 'a.js')
    with open(source, 'w') as f:
        f.write('square = (x) -> x * x')
    compiler.process(source, target)

    assert 'square = function(x) {' in open(target).read()
Beispiel #11
0
def test_sass_compiler(tmpdir):
    compiler = fanstatic.CompilerRegistry.instance()['sass']
    if not compiler.available:
        pytest.skip('`%s` not found on PATH' % compiler.command)
    compiler.arguments = ['--no-cache'] + compiler.arguments

    # from http://sass-lang.com/tutorial.html :
    source = str(tmpdir / 'a.scss')
    target = str(tmpdir / 'a.css')
    with open(source, 'w') as f:
        f.write('''\
#navbar {
  li {
    a { font-weight: bold; }
  }
}''')
    compiler.process(source, target)
    assert '#navbar li a' in open(target).read()
def test_sass_compiler(tmpdir):
    compiler = fanstatic.CompilerRegistry.instance()['sass']
    if not compiler.available:
        pytest.skip('`%s` not found on PATH' % compiler.command)
    compiler.arguments = ['--no-cache'] + compiler.arguments

    # from http://sass-lang.com/tutorial.html :
    source = str(tmpdir / 'a.scss')
    target = str(tmpdir / 'a.css')
    with open(source, 'w') as f:
        f.write('''\
#navbar {
  li {
    a { font-weight: bold; }
  }
}''')
    compiler.process(source, target)
    assert '#navbar li a' in open(target).read()