def test_just_comment(self): test_file = "# test comment" expected = [] with patch('builtins.open', mock_open(read_data=test_file)): output = pkglist.parsePkgList("foo") self.assertEqual(output, expected)
def test_extra_spaces(self): test_file = " pkg \n pkg2" expected = ["pkg", "pkg2"] with patch('builtins.open', mock_open(read_data=test_file)): output = pkglist.parsePkgList("foo") self.assertEqual(output, expected)
def test_multiple_packages_multiple_comments(self): test_file = "pkg # test comment\npkg2 #with another comment\n# no package, just comment" expected = ["pkg", "pkg2"] with patch('builtins.open', mock_open(read_data=test_file)): output = pkglist.parsePkgList("foo") self.assertEqual(output, expected)
def test_single_package_with_comment(self): test_file = "pkg # test comment" expected = ["pkg"] with patch('builtins.open', mock_open(read_data=test_file)): output = pkglist.parsePkgList("foo") self.assertEqual(output, expected)
def getPackagesByConfig(self, path): pkgs = {} for c in self.getConfigs(path): pkgs[c] = parsePkgList(c) return pkgs
def getPackages(self, path): pkgs = set() for c in self.getConfigs(path): pkgs = pkgs.union(set(parsePkgList(c))) return pkgs