Esempio n. 1
0
    def handle(self, *args, **options):
        path = options.get('path')
        ignore_hacks = options.get('ignore-hacks')

        if not path:
            path = settings.MEDIA_ROOT
            if not path:
                print "You did not pass the argument --path and don't " \
                      "even have settings.MEDIA_ROOT set. The command " \
                      "can not proceed :("
            else:
                print "Scanning css files under settings.MEDIA_ROOT: " \
                      "%s" % path
        else:
            print "Scanning css files under: %s" % path
        valid_files = []
        invalid_files = []
        for filename in CSSLint.fetch_css(path):
            content = open(filename).read()
            cssl = CSSLint(content)
            try:
                cssl.validate(ignore_hacks=ignore_hacks)
                valid_files.append(filename)
            except InvalidCSSError, e:
                invalid_files.append((filename, e))
 def test_should_validate_ok(self):
     'CSSLint("a valid css") should validate successfully'
     css_ok = """
         #some {
             color: blue;
         }
     """
     css = CSSLint(css_ok)
     assert css.validate() is True, 'Should validate successfully'