mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-19 08:26:23 -07:00
Fix deepsource issues
This commit is contained in:
parent
5ae229d61e
commit
74f9e415b4
7 changed files with 12 additions and 13 deletions
|
@ -31,7 +31,6 @@ import (
|
|||
|
||||
var (
|
||||
lState *lua.LState
|
||||
eventPlugins map[string][]*lua.LFunction
|
||||
ErrInvalidInitFunc = errors.New("invalid InitPlugin, expected function with 0 arguments and 1 return value (error type)")
|
||||
)
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ func ApplyDiceRoll(p *gcsql.Post) (rollSum int, err error) {
|
|||
return 0, fmt.Errorf("dice roll too small")
|
||||
}
|
||||
for i := 0; i < numDice; i++ {
|
||||
rollSum += rand.Intn(dieSize) + 1
|
||||
rollSum += rand.Intn(dieSize) + 1 // skipcq: GSC-G404
|
||||
switch roll[3] {
|
||||
case "+":
|
||||
mod, err := strconv.Atoi(roll[4])
|
||||
|
|
|
@ -11,8 +11,8 @@ from os import path
|
|||
import sys
|
||||
|
||||
VERSION = "v3.10.2"
|
||||
DIR = "gochan-{}_linux".format(VERSION)
|
||||
DOWNLOAD_URL = "https://github.com/gochan-org/gochan/releases/download/{}/{}.tar.gz".format(VERSION, DIR)
|
||||
DIR = f"gochan-{VERSION}_linux"
|
||||
DOWNLOAD_URL = f"https://github.com/gochan-org/gochan/releases/download/{VERSION}/{DIR}.tar.gz"
|
||||
JS_DIR = path.join(DIR, "html/js/")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -20,7 +20,7 @@ if __name__ == "__main__":
|
|||
if len(sys.argv) == 2:
|
||||
match sys.argv[1]:
|
||||
case "-h" | "--help":
|
||||
print("usage: {} [path/to/out/js/]".format(sys.argv[0]))
|
||||
print(f"usage: {sys.argv[0]} [path/to/out/js/]")
|
||||
sys.exit(0)
|
||||
case _:
|
||||
out_dir = sys.argv[1]
|
||||
|
|
|
@ -132,7 +132,7 @@ class TestingOptions:
|
|||
case ""|None:
|
||||
raise ValueError("browser argument is required")
|
||||
case _:
|
||||
raise ValueError("Unrecognized browser argument %s" % browser)
|
||||
raise ValueError(f"Unrecognized browser argument {browser}")
|
||||
|
||||
|
||||
def boards_json(self) -> dict[str, object]:
|
||||
|
|
|
@ -21,7 +21,7 @@ def start_tests(dict_options:dict[str,object]=None):
|
|||
options = TestingOptions.from_dict(dict_options)
|
||||
set_active_options(options)
|
||||
single_test = dict_options.get("single_test", "")
|
||||
print("Using browser %s (headless: %s) on site %s" % (options.browser, options.headless, options.site))
|
||||
print(f"Using browser {options.browser} (headless: {options.headless}) on site {options.site}")
|
||||
if single_test == "":
|
||||
suite = unittest.suite.TestSuite()
|
||||
SeleniumTestCase.add(suite, options, TestPosting)
|
||||
|
@ -69,7 +69,7 @@ def setup_selenium_args(parser:ArgumentParser):
|
|||
parser.add_argument("--keep-open", action="store_true",
|
||||
help="If set, the browser windows will not automatically close after the tests are complete")
|
||||
parser.add_argument("--site", default=default_site,
|
||||
help=("Sets the site to be used for testing, defaults to %s" % default_site))
|
||||
help=f"Sets the site to be used for testing, defaults to {default_site}")
|
||||
parser.add_argument("--board1", default=default_board1,
|
||||
help="Sets the main board to be used for testing. It must already be created or tests that use it will fail")
|
||||
parser.add_argument("--board2", default=default_board2,
|
||||
|
@ -102,14 +102,14 @@ def setup_selenium_args(parser:ArgumentParser):
|
|||
help="Sets the password to be used when logging in as a janitor. Janitor tests will fail if this does not exist")
|
||||
parser.add_argument("--single-test", default="",
|
||||
help="If specified, only the test method with this name will be run")
|
||||
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser(description="Browser testing via Selenium")
|
||||
args = setup_selenium_args(parser)
|
||||
|
||||
|
||||
try:
|
||||
start_tests(args.__dict__)
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
@ -63,11 +63,11 @@ class TestPosting(SeleniumTestCase):
|
|||
|
||||
cur_url = self.driver.current_url
|
||||
threadID = threadRE.findall(cur_url)[0][1]
|
||||
self.driver.find_element(by=By.CSS_SELECTOR, value=("input#check%s"%threadID)).click()
|
||||
self.driver.find_element(by=By.CSS_SELECTOR, value=f"input#check{threadID}").click()
|
||||
cur_url = self.driver.current_url
|
||||
self.driver.find_element(by=By.CSS_SELECTOR, value="input[name=move_btn]").click()
|
||||
# wait for response to move_btn
|
||||
WebDriverWait(self.driver, 10).until(EC.title_contains("Move thread #%s" % threadID))
|
||||
WebDriverWait(self.driver, 10).until(EC.title_contains(f"Move thread #{threadID}"))
|
||||
|
||||
self.driver.find_element(by=By.CSS_SELECTOR, value="input[type=submit]").click()
|
||||
# wait for response to move request (domove=1)
|
||||
|
|
|
@ -52,7 +52,7 @@ def delete_post(options: TestingOptions, postID:int, password:str):
|
|||
qr_buttons = options.driver.find_element(by=By.ID, value="qr-buttons")
|
||||
if qr_buttons.is_displayed():
|
||||
qr_buttons.find_element(by=By.LINK_TEXT, value="X").click()
|
||||
options.driver.find_element(by=By.CSS_SELECTOR, value=("input#check%s"%postID)).click()
|
||||
options.driver.find_element(by=By.CSS_SELECTOR, value=f"input#check{postID}").click()
|
||||
if password != "":
|
||||
delPasswordInput = options.driver.find_element(
|
||||
by=By.CSS_SELECTOR,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue