Skip to content

Commit

Permalink
ci: fix test suite (#1354)
Browse files Browse the repository at this point in the history
* chore: raise min python to 3.6.7

* ci(lint-test): update actions

* chore: lint

* test: fix for windows

path resolution was not padding slashes enough on windows in
illegal-chars

* chore: update test suite and dependencies

note the removal of futures in this commit.
this removes the need for #1353 but it was necessary to clear setuptools legacy.
  • Loading branch information
Nytelife26 authored Jan 24, 2024
1 parent 56d4772 commit 629af47
Show file tree
Hide file tree
Showing 9 changed files with 1,029 additions and 916 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
shell: bash
strategy:
matrix:
python: [3.9]
python: ["3.10"]
steps:
- name: "[INIT] Checkout repository"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "[INIT] Install Python ${{ matrix.python }}"
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: "[INIT] Install Poetry"
uses: snok/install-poetry@v1.3
- name: "[INIT] Restore dependency cache"
id: cache-restore
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cache/pip
Expand All @@ -36,26 +36,26 @@ jobs:
test-cover:
name: Test & Cover
if: "!(contains(github.event.head_commit.message, '[skip_ci]'))"
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9, pypy3]
python: ["3.8", "3.9", "3.10", "pypy3.9", "pypy3.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: "[INIT] Checkout repository"
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: "[INIT] Install Python ${{ matrix.python }}"
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: "[INIT] Install Poetry"
uses: snok/install-poetry@v1.3
- name: "[INIT] Restore dependency cache"
id: cache-restore
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cache/pip
Expand All @@ -67,7 +67,7 @@ jobs:
- name: "[EXEC] Test"
run: ./utils ci test --coverage
- name: "[EXEC] Upload coverage to Codecov"
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
flags: ${{ matrix.os }},py${{ matrix.python }}
1,865 changes: 990 additions & 875 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion proselint/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def lint(input_file, debug=False, config=config.default):
def assert_error(text, check, n=1):
"""Assert that text has n errors of type check."""
assert_error.description = f"No {check} error for '{text}'"
assert(check in [error[0] for error in lint(text)])
assert len([error[0] for error in lint(text) if error[0] == check]) == n


def consistency_check(text, word_pairs, err, msg, offset=0):
Expand Down
24 changes: 10 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ readme = "README.md"
homepage = "https://proselint.com"
repository = "https://github.com/amperser/proselint"
classifiers = ["Programming Language :: Python :: Implementation :: CPython"]
include = [
"proselint/",
"tests/",
"proselint/demo.md",
]
include = ["proselint/", "tests/", "proselint/demo.md"]
exclude = ["tests/.gitignore"]

[tool.poetry.dependencies]
python = "^3.6.1"
python = "^3.8.1"
click = "^8.0.0"

[tool.poetry.dev-dependencies]
gmail = {git = "https://github.com/charlierguo/gmail.git"}
[tool.poetry.group.dev.dependencies]
gmail = { git = "https://github.com/charlierguo/gmail.git" }
APScheduler = ">=3.5.3"
bumpversion = ">=0.5.3"
coverage = "^6.1"
Expand All @@ -30,16 +26,16 @@ Flask = ">=1.1.4"
Flask-Limiter = ">=1.0.1"
gunicorn = ">=19.8.1"
mock = ">=2.0.0"
pytest = "^6.2.5"
pytest = "^7.4.0"
redis = ">=2.10.6"
requests = ">=2.19.1"
rq = ">=0.12.0"
pydocstyle = "^6.1.1"
pydocstyle = "^6.3.0"
twine = "^3.5.0"
flake8 = "^4.0.1"
flake8-bugbear = "^22.1.11"
flake8-import-order = "^0.18.1"
isort = "^5.10.0"
flake8 = "^6.1.0"
flake8-bugbear = "^23.7.10"
flake8-import-order = "^0.18.2"
isort = "^5.12.0"

[tool.poetry.scripts]
proselint = "proselint.command_line:proselint"
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 10 additions & 8 deletions tests/test_config_flag.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test user option overrides using --config and load_options"""
import json
import os
from pathlib import Path
from unittest import TestCase
from unittest.mock import patch

Expand All @@ -12,6 +13,9 @@

runner = CliRunner()

CONFIG_FILE = str(Path(__file__, "../test-proselintrc.json").resolve())
FLAG = f"--config '{CONFIG_FILE}'"


def test_deepmerge_dicts():
"""Test deepmerge_dicts"""
Expand All @@ -24,9 +28,9 @@ def test_deepmerge_dicts():
def test_load_options_function(isfile):
"""Test load_options by specifying a user options path"""

isfile.side_effect = "tests/test_config_flag_proselintrc.json".__eq__
isfile.side_effect = CONFIG_FILE.__eq__

overrides = load_options("tests/test_config_flag_proselintrc.json", default)
overrides = load_options(CONFIG_FILE, default)
assert load_options(conf_default=default)["checks"]["uncomparables.misc"]
assert not overrides["checks"]["uncomparables.misc"]

Expand All @@ -40,9 +44,9 @@ def test_config_flag():
output = runner.invoke(proselint, "--demo")
assert "uncomparables.misc" in output.stdout

output = runner.invoke(
proselint, "--demo --config tests/test_config_flag_proselintrc.json")
output = runner.invoke(proselint, f"--demo {FLAG}")
assert "uncomparables.misc" not in output.stdout
assert "FileNotFoundError" != output.exc_info[0].__name__

output = runner.invoke(proselint, "--demo --config non_existent_file")
assert output.exit_code == 1
Expand All @@ -57,7 +61,5 @@ def test_dump_config():
output = runner.invoke(proselint, "--dump-default-config")
assert json.loads(output.stdout) == default

output = runner.invoke(
proselint, "--dump-config --config tests/test_config_flag_proselintrc.json")
assert json.loads(output.stdout) == json.load(
open("tests/test_config_flag_proselintrc.json"))
output = runner.invoke(proselint, f"--dump-config {FLAG}")
assert json.loads(output.stdout) == json.load(open(CONFIG_FILE))
10 changes: 5 additions & 5 deletions tests/test_illegal_chars.py → tests/test_invalid_chars.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
"""Check that the CLI can handle invalid characters."""

from os.path import abspath, dirname, join
from pathlib import Path

from click.testing import CliRunner

from proselint.command_line import proselint

from .check import Check

CHAR_FILE = Path(__file__, "../invalid-chars.txt").resolve()


class TestInvalidCharacters(Check):
"""Test class for testing invalid characters on the CLI"""

__test__ = True

def test_invalid_characters(self):
"""Ensure that a file with illegal characters does not break us."""
curr_dir = dirname(abspath(__file__))
test_file = join(curr_dir, "illegal-chars.txt")
"""Ensure that invalid characters do not break proselint."""
runner = CliRunner()

output = runner.invoke(proselint, test_file)
output = runner.invoke(proselint, CHAR_FILE)

assert "UnicodeDecodeError" not in output.stdout
assert "FileNotFoundError" not in output.stdout
6 changes: 3 additions & 3 deletions tests/test_topic_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def test_50_Cent_detector_on_topic():
of the world's best selling rappers and rose to prominence with
East Coast hip hop group G-Unit (which he leads de facto). """

assert("50 Cent" in topics(text))
assert "50 Cent" in topics(text)

text = """Hip hop was started in the early 50's."""
assert("50 Cent" not in topics(text))
assert "50 Cent" not in topics(text)

text = """Nowadays it costs 50 cents to buy a lollipop."""
assert("50 Cent" not in topics(text))
assert "50 Cent" not in topics(text)

0 comments on commit 629af47

Please sign in to comment.