Example #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'
 def test_can_find_css_files_for_given_path(self):
     'CSSLint.fetch_css should find css files within a given path'
     css_files = CSSLint.fetch_css(LOCAL_FILE('media'))
     self.assertTrue(isinstance(css_files, list))
     self.assertEquals(len(css_files), 2)
     self.assertEquals(css_files[0], LOCAL_FILE('media', 'css', 'invalid-css1.css'))
     self.assertEquals(css_files[1], LOCAL_FILE('media', 'css', 'valid', 'valid-css1.css'))
 def test_find_and_check_css_success(self):
     'CSSLint.fetch_and_check should find and check css files'
     assert CSSLint.check_files(LOCAL_FILE('media','css', 'valid')) is True, 'Should check successfully'