def setUp(self): # create the project dir self.project_dir = tempfile.mkdtemp() os.environ['test_project_dir'] = self.project_dir # the less file to compile self.dummy_view = DummyView(self.project_dir) # create the dummy less file open(self.dummy_view.file_name(), 'w').close() # the compiler self.compiler = Compiler(self.dummy_view)
class TestOuputDir(unittest.TestCase): def setUp(self): # create the project dir self.project_dir = tempfile.mkdtemp() os.environ['test_project_dir'] = self.project_dir # the less file to compile self.dummy_view = DummyView(self.project_dir) # create the dummy less file open(self.dummy_view.file_name(), 'w').close() # the compiler self.compiler = Compiler(self.dummy_view) def test_absolute_path_same_name(self): print "Running %s" % self._testMethodName # Providing an absolute path inside the project dir # because that's in tmp and we have write access # but should work with any path self.output = os.path.join(self.project_dir, 'absolute') # something like /tmp/tmpJshx/absolute self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output)) # open the created file with open(os.path.join(self.output, LESS_FILE.replace(".less", ".css")), "r") as f: self.assertIsInstance(f, file) def test_absolute_path_provided_name(self): print "Running %s" % self._testMethodName # Providing an absolute path inside the project dir # because that's in tmp and we have write access # but should work with any path self.output = os.path.join(self.project_dir, 'absolute') # something like /tmp/tmpJshx/absolute self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output), outputFile=CSS_FILE) # open the created file with open(os.path.join(self.output, CSS_FILE), "r") as f: self.assertIsInstance(f, file) def test_relative_path_same_name(self): print "Running %s" % self._testMethodName self.output = 'relative/path' # something like /tmp/tmpJshx/relative/path self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output)) # open the created file with open(os.path.join(self.project_dir, self.output, LESS_FILE.replace(".less", ".css")), "r") as f: self.assertIsInstance(f, file) def test_relative_path_provided_name(self): print "Running %s" % self._testMethodName self.output = 'relative/path' # something like /tmp/tmpJshx/relative/path self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output), outputFile=CSS_FILE) # open the created file with open(os.path.join(self.project_dir, self.output, CSS_FILE), "r") as f: self.assertIsInstance(f, file) def test_dot_path_same_name(self): print "Running %s" % self._testMethodName self.output = './' self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output)) # open the created file with open(os.path.join(self.project_dir, self.output, LESS_FILE.replace(".less", ".css")), "r") as f: self.assertIsInstance(f, file) def test_dot_path_provided_name(self): print "Running %s" % self._testMethodName self.output = './' self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output), outputFile=CSS_FILE) # open the created file with open(os.path.join(self.project_dir, self.output, CSS_FILE), "r") as f: self.assertIsInstance(f, file) def test_empty_path_same_name(self): print "Running %s" % self._testMethodName self.output = '' self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output)) # open the created file with open(os.path.join(self.project_dir, self.output, LESS_FILE.replace(".less", ".css")), "r") as f: self.assertIsInstance(f, file) def test_empty_path_provided_name(self): print "Running %s" % self._testMethodName self.output = '' self.compiler.convertLess2Css(self.compiler.parseBaseDirs(BASE_DIR, self.output), outputFile=CSS_FILE) # open the created file with open(os.path.join(self.project_dir, self.output, CSS_FILE), "r") as f: self.assertIsInstance(f, file)