def testFileOnly(self): """Test behavior when passed a filename only.""" v = utils.splitpath_root_file_ext(r'spam.eggs') self.assertEqual(v, ('', 'spam', '.eggs')) v = utils.splitpath_root_file_ext(r'spam') self.assertEqual(v, ('', 'spam', '')) v = utils.splitpath_root_file_ext('.eggs') self.assertEqual(v, ('', '.eggs', ''))
def testFileOnly(self): """Test behavior when passed a filename only.""" v = utils.splitpath_root_file_ext(r'spam.eggs') self.assertEqual(v, ('', 'spam', '.eggs')) v = utils.splitpath_root_file_ext(r'spam') self.assertEqual(v, ('', 'spam', '')) v = utils.splitpath_root_file_ext('.eggs') self.assertEqual(v, ('', '.eggs', ''))
def measure_file_complexity(filename): """Returns a FlatStats object for the contents of the file at filename.""" modulename = utils.splitpath_root_file_ext(filename)[1] ast = compiler.parseFile(filename) ast.name = modulename visitor = CCVisitor(ast) return FlatStats(visitor.stats)
def testDirOnly(self): """Test behavior when passed a path only.""" v = utils.splitpath_root_file_ext(r'C:\foo\bar') self.assertEqual(v, ('C:\\foo', 'bar', '')) v = utils.splitpath_root_file_ext('C:\\') self.assertEqual(v, ('C:\\', '', ''))
def testRegularPath(self): """Test the method's behavior on regular paths.""" v = utils.splitpath_root_file_ext(r'F:\foo\bar.py') self.assertEqual(v, ('F:\\foo', 'bar', '.py')) v = utils.splitpath_root_file_ext((r'J:\spam.py')) self.assertEqual(v, ('J:\\', 'spam', '.py'))
def testDirOnly(self): """Test behavior when passed a path only.""" v = utils.splitpath_root_file_ext(r'C:\foo\bar') self.assertEqual(v, ('C:\\foo', 'bar', '')) v = utils.splitpath_root_file_ext('C:\\') self.assertEqual(v, ('C:\\', '', ''))
def testRegularPath(self): """Test the method's behavior on regular paths.""" v = utils.splitpath_root_file_ext(r'F:\foo\bar.py') self.assertEqual(v, ('F:\\foo', 'bar', '.py')) v = utils.splitpath_root_file_ext((r'J:\spam.py')) self.assertEqual(v, ('J:\\', 'spam', '.py'))
def measure_file_complexity(filename): """Returns a FlatStats object for the contents of the file at filename.""" ast = compiler.parseFile(filename) return measure_complexity(ast, module_name=utils.splitpath_root_file_ext(filename)[1])