def testSimple(self): manifest_string = '\r\n'.join([ 'Manifest-Version: 1.0', 'Created-By: ManifestParseTest', '', 'Name: com/google/appengine/api/', 'Implementation-Vendor: Google', 'Specification-Version: 1.0', '', 'Name: com/google/something/else/', 'This: that', ]) manifest = jarfile._ParseManifest(manifest_string, 'dummy.jar') self.assertEqual(manifest.main_section, { 'Manifest-Version': '1.0', 'Created-By': 'ManifestParseTest', }) self.assertEqual( manifest.sections, { 'com/google/appengine/api/': { 'Name': 'com/google/appengine/api/', 'Implementation-Vendor': 'Google', 'Specification-Version': '1.0', }, 'com/google/something/else/': { 'Name': 'com/google/something/else/', 'This': 'that', }, })
def testUnicode(self): manifest_string = u'\r\n'.join([ 'Manifest-Version: 1.0', 'Created-By: ManifestParseTest', '', 'Name: one', 'One: 1', '', 'Name: two', 'Two: 2', ]) manifest = jarfile._ParseManifest(manifest_string, 'dummy.jar') self.assertEqual(manifest.main_section, { 'Manifest-Version': '1.0', 'Created-By': 'ManifestParseTest', }) self.assertEqual(manifest.sections, { 'one': { 'Name': 'one', 'One': '1', }, 'two': { 'Name': 'two', 'Two': '2', }, })
def testManifestOnly(self): manifest_string = '\r\n'.join([ 'Manifest-Version: 1.0', 'Created-By: ManifestParseTest', '', ]) manifest = jarfile._ParseManifest(manifest_string, 'dummy.jar') self.assertEqual(manifest.main_section, { 'Manifest-Version': '1.0', 'Created-By': 'ManifestParseTest', }) self.assertEqual(manifest.sections, {})
def testTrailingBlanks(self): manifest_string = '\r\n'.join([ 'Manifest-Version: 1.0', 'Created-By: ManifestParseTest', '', 'Name: com/google/appengine/api/', 'Implementation-Vendor: Google', 'Specification-Version: 1.0', '', 'Name: com/google/something/else/', 'This: that', '', ]) manifest = jarfile._ParseManifest(manifest_string, 'dummy.jar') self.assertEqual(len(manifest.sections), 2)
def testContinuationLines(self): manifest_string = '\r\n'.join([ 'Manifest-Version: 1', ' .0', 'Created-By: ManifestParseTest', '', 'Name: com/google/', ' appengine/api/', 'Implementation-Vendor: Go', ' ogle', ]) manifest = jarfile._ParseManifest(manifest_string, 'dummy.jar') self.assertEqual(manifest.main_section, { 'Manifest-Version': '1.0', 'Created-By': 'ManifestParseTest', }) self.assertEqual( manifest.sections, { 'com/google/appengine/api/': { 'Name': 'com/google/appengine/api/', 'Implementation-Vendor': 'Google', }, })
def testEmptyManifest(self): manifest_string = '\r\n' manifest = jarfile._ParseManifest(manifest_string, 'dummy.jar') self.assertEqual(manifest.main_section, {}) self.assertEqual(manifest.sections, {})