def test_makeBranchTrailingSlash(self): """makeBranch creates a mirrored branch even if the URL ends with /. """ uri = URI(self.factory.getUniqueURL()) expected_name = self.popup.getBranchNameFromURL( str(uri.ensureNoSlash())) branch = self.popup.makeBranchFromURL(str(uri.ensureSlash())) self.assertEqual(str(uri.ensureNoSlash()), branch.url) self.assertEqual(expected_name, branch.name)
def normalize(self, input): """See `IURIField`.""" if input is None: return input try: uri = URI(input) except InvalidURIError as exc: raise LaunchpadValidationError(str(exc)) # If there is a policy for whether trailing slashes are # allowed at the end of the path segment, ensure that the # URI conforms. if self.trailing_slash is not None: if self.trailing_slash: uri = uri.ensureSlash() else: uri = uri.ensureNoSlash() input = unicode(uri) return input