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)
def test_ipython_html2text():
assert converters.html2text(ipython_html) == ipython_plaintext
def test_html2text():
assert converters.html2text(html) == plaintext
def test_languages_request():
langs = api.get_languages(API_BASE_URL)
assert isinstance(langs, list)
assert len(langs) > 2
found_german = False
for i, dic in enumerate(langs):
if dic["code"] == "de":
found_german = True
assert found_german
def test_markdown2html():
assert converters.markdown2html(markdown) == html
def test_ipython_markdown2html():
assert converters.markdown2html(ipython_markdown) == ipython_html
def test_ipynb2markdown():
assert converters.ipynb2markdown(ipython) == ipython_markdown
✗ das ist ein est
^^^
✓ Das ist ein est
Möglicher Rechtschreibfehler gefunden
✗ das ist ein est
^^^
✓ das ist ein ist
✓ das ist ein es
✓ das ist ein erst
✓ das ist ein fest
✓ das ist ein West
Text checked by https://example.com/v2/ (LanguageTool 4.6)
"""
pylanguagetool.print_errors(response, "https://example.com/v2/", False)
out, err = capsys.readouterr()
assert out == should_output
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)