def lint_user_code(self, data): file_, ext = os.path.split(self.options.target) file_ += "pre" + ext fd = open(file_, "w") fd.write(data) fd.close() jsl = JavaScriptLint() jsl.path = file_ if not jsl.lint(): print jsl.output_reg print jsl.output_err sys.exit(1) os.remove(file_)
class TestJavascriptLin(unittest.TestCase): def setUp(self): self.jsl = JavaScriptLint() def test_produces_no_output_with_no_input(self): self.assertTrue(self.jsl.lint()) def test_produces_output_with_bad_input(self): data = util.data_from_test_file(r"badjs\test.js") self.assertFalse(self.jsl.lint(data)) def test_produces_no_output_with_good_input(self): data = "alert('hello');" self.assertTrue(self.jsl.lint(data)) def test_produces_output_with_bad_file(self): self.jsl.path = util.test_path(r"badjs\test.js") self.assertFalse(self.jsl.lint()) def test_produces_output_with_wildcard_bad(self): self.jsl.path = util.test_path("*.js") self.assertFalse(self.jsl.lint()) def test_produces_no_output_with_wildcard_good(self): self.jsl.path = util.test_path(r"goodjs\*.js") self.assertTrue(self.jsl.lint()) def test_produces_no_output_with_good_file(self): self.jsl.path = util.test_path(r"goodjs\test.js") self.assertTrue(self.jsl.lint(),self.jsl.output_reg+'\n'+self.jsl.output_err)
def setUp(self): self.jsl = JavaScriptLint()