Skip to content

Commit

Permalink
Change default for redirect param of create() and login() to None
Browse files Browse the repository at this point in the history
Fix the following mypy error:

```
lib/tool_shed/test/functional/test_frontend_login.py:76: error: Argument
"redirect" to "login" of "ShedTwillTestCase" has incompatible type "None";
expected "str"  [arg-type]
            self.login(email, TEST_PASSWORD, username=user, redirect=None)
                                                                     ^
```
  • Loading branch information
nsoranzo committed Oct 24, 2023
1 parent e59c188 commit 256a81f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lib/tool_shed/test/base/twilltestcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Iterator,
List,
Optional,
Tuple,
)
from urllib.parse import (
quote_plus,
Expand Down Expand Up @@ -694,7 +695,14 @@ def _submit_register_form(self, email: str, password: str, username: str, redire
def invalid_tools_labels(self) -> str:
return "Invalid Tools" if self.is_v2 else "Invalid tools"

def create(self, cntrller="user", email="[email protected]", password="testuser", username="admin-user", redirect=""):
def create(
self,
cntrller: str = "user",
email: str = "[email protected]",
password: str = "testuser",
username: str = "admin-user",
redirect: Optional[str] = None,
) -> Tuple[bool, bool, bool]:
# HACK: don't use panels because late_javascripts() messes up the twill browser and it
# can't find form fields (and hence user can't be logged in).
params = dict(cntrller=cntrller, use_panels=False)
Expand Down Expand Up @@ -747,7 +755,7 @@ def login(
email: str = "[email protected]",
password: str = "testuser",
username: str = "admin-user",
redirect: str = "",
redirect: Optional[str] = None,
logout_first: bool = True,
):
if self.is_v2:
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/test/functional/test_frontend_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def _create_and_login(self):
password=TEST_PASSWORD,
username=user,
)
self.login(email, TEST_PASSWORD, username=user, redirect=None)
self.login(email, TEST_PASSWORD, username=user)

0 comments on commit 256a81f

Please sign in to comment.