Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_request():
response = api.check("This is an test", API_BASE_URL, "auto")
assert "software" in response
match = response["matches"][0]
assert isinstance(match, dict)
sys.exit(2)
if config["input_type"]:
inputtype = config["input_type"]
if inputtype == "tex":
print("pyLanguagetool doesn't support LaTeX out of the box.")
print("But it doesn't have to:")
print("You can simply use the output of detex")
if config["input file"]:
print(" $ detex {} | pylanguagetool".format(config["input file"]))
print("or use the languagetool integration in TeXstudio.")
sys.exit(3)
check_text = converters.convert(input_text, inputtype)
if config["single_line"]:
found = False
for line in check_text.splitlines():
response = api.check(line, **config)
print_errors(response,
config["api_url"],
not config["no_color"],
config["rules"],
config["rule_categories"]
)
if len(response["matches"]) > 0:
found = True
if found:
sys.exit(1)
else:
response = api.check(check_text, **config)
print_errors(response,
config["api_url"],
not config["no_color"],
found = False
for line in check_text.splitlines():
response = api.check(line, **config)
print_errors(response,
config["api_url"],
not config["no_color"],
config["rules"],
config["rule_categories"]
)
if len(response["matches"]) > 0:
found = True
if found:
sys.exit(1)
else:
response = api.check(check_text, **config)
print_errors(response,
config["api_url"],
not config["no_color"],
config["rules"],
config["rule_categories"],
config["explain_rule"]
)
if len(response["matches"]) > 0:
sys.exit(1)