def create_hosting_account(self, use_url=None, local_site=None, data=None): """Create a hosting account to test with. Args: use_url (unicode, optional): Whether the account should be attached to a given hosting URL, for self-hosted services. If set, this will use ``https://example.com``. local_site (reviewboard.site.models.LocalSite, optional): A Local Site to attach the account to. data (dict, optional): Optional data to set for the account. If this is ``None``, :py:attr:`default_account_data` will be used. Returns: reviewboard.hostingsvcs.models.HostingServiceAccount: The new hosting service account. """ if use_url is None: use_url = self.default_use_hosting_url if use_url: hosting_url = self.default_hosting_url else: hosting_url = None account = HostingServiceAccount(service_name=self.service_name, username=self.default_username, hosting_url=hosting_url, local_site=local_site) if data is not None: account.data = data else: account.data = self.default_account_data account.save() return account