Exemplo n.º 1
0
def test_watch_initial_compile(tmpdir):
    src, dest = _setup_tmpdir(tmpdir)

    pylibsass.watch(src.strpath, dest.strpath)

    files = map(lambda f: f.basename, dest.listdir())

    assert set(files) == set(["test.css", "test2.css"])
Exemplo n.º 2
0
def test_watch_initial_compile(tmpdir):
    src, dest = _setup_tmpdir(tmpdir)

    pylibsass.watch(src.strpath, dest.strpath)

    files = map(lambda f: f.basename, dest.listdir())

    assert set(files) == set(["test.css", "test2.css"])
Exemplo n.º 3
0
def test_watch_file_added(tmpdir):
    import time
    src, dest = _setup_tmpdir(tmpdir)

    pylibsass.watch(src.strpath, dest.strpath)

    f = src.join("test3.scss")
    f.write(".test3 { .test3-inner { width: 300px; } }")

    # Give enough time for event to be triggered
    time.sleep(0.05)

    files = map(lambda f: f.basename, dest.listdir())

    assert set(files) == set(["test.css", "test2.css", "test3.css"])
Exemplo n.º 4
0
def test_watch_file_added(tmpdir):
    import time
    src, dest = _setup_tmpdir(tmpdir)

    pylibsass.watch(src.strpath, dest.strpath)

    f = src.join("test3.scss")
    f.write(".test3 { .test3-inner { width: 300px; } }")

    # Give enough time for event to be triggered
    time.sleep(0.05)

    files = map(lambda f: f.basename, dest.listdir())

    assert set(files) == set(["test.css", "test2.css", "test3.css"])
Exemplo n.º 5
0
    def runserver(self, port=None):
        """
        run the tornado web server and watch for sass changes
        """
        if port == None:
            port = self.port

        try:
            # watch for sass changes
            pylibsass.watch(os.path.join(self.source_path, 'scss'),
                            os.path.join(self.source_path, 'css'))

            # setup the server
            tornado.autoreload.add_reload_hook(self.reload_hook)
            tornado.autoreload.start()
            self.application.listen(port)

            print('now serving on port %s...' % port)
            tornado.ioloop.IOLoop.instance().start()
        except KeyboardInterrupt as e:
            pass
        except socket.error:
            print('port %s is already in use.' % (port))