diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ca256aa --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,77 @@ +name: Build and test + +on: + push: + branches: + - master + tags: + pull_request: + +jobs: + test: + strategy: + matrix: + py: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12-dev" + - "pypy-3.9" + os: + - "ubuntu-20.04" + - "macos-latest" + architecture: + - x64 + + exclude: + # persistent fails to build on 3.12-dev on MacOS in GitHub + - os: macos-latest + py: "3.12-dev" + + include: + # Only run coverage on ubuntu-20.04, except on pypy3 + - os: "ubuntu-20.04" + pytest-args: "--cov" + - os: "ubuntu-20.04" + py: "pypy-3.9" + pytest-args: "" + + + name: "Python: ${{ matrix.py }}-${{ matrix.architecture }} on ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.py }} + architecture: ${{ matrix.architecture }} + - run: pip install tox + - name: Running tox + run: tox -e py -- ${{ matrix.pytest-args }} + coverage: + runs-on: ubuntu-20.04 + name: Validate coverage + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + architecture: x64 + - run: pip install tox + - run: tox -e coverage + docs: + runs-on: ubuntu-20.04 + name: Build the documentation + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + architecture: x64 + - run: pip install tox + - run: tox -e docs diff --git a/.gitignore b/.gitignore index 50efb09..9087ddf 100644 --- a/.gitignore +++ b/.gitignore @@ -10,9 +10,12 @@ hypatia/coverage.xml coverage-py*.xml coverage.xml env*/ +.venv .build/ bin/ include/ lib/ build/ *.so +.idea +.envrc diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 87049a5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Wire up travis -language: python -sudo: false - -matrix: - include: - - python: 2.7 - env: TOXENV=py27 - - python: 3.6 - env: TOXENV=py36 - - python: 3.7 - env: TOXENV=py37 - - python: 3.8 - env: TOXENV=py38 - - python: 3.9 - env: TOXENV=py39 - - python: 3.10 - env: TOXENV=py310 - -install: - - travis_retry pip install tox - -script: - - travis_retry tox - -notifications: - email: - - pyramid-checkins@lists.repoze.org - irc: - channels: - - "chat.freenode.net#pyramid" diff --git a/README.rst b/README.rst index 6e9801c..3ec081c 100644 --- a/README.rst +++ b/README.rst @@ -5,8 +5,9 @@ Hypatia :target: https://pypi.python.org/pypi/hypatia/ :alt: Latest Version -.. image:: https://travis-ci.org/Pylons/hypatia.png?branch=master - :target: https://travis-ci.org/Pylons/hypatia +.. image:: https://github.com/Pylons/hypatia/workflows/Build%20and%20test/badge.svg?branch=master + :target: https://github.com/Pylons/hypatia/actions/workflows/main.yml + :alt: CI Status .. image:: https://readthedocs.org/projects/hypatia/badge/?version=latest :target: http://hypatia.readthedocs.org/en/latest/ diff --git a/hypatia/field/tests.py b/hypatia/field/tests.py index e1a5c08..a9d39d1 100644 --- a/hypatia/field/tests.py +++ b/hypatia/field/tests.py @@ -1366,7 +1366,7 @@ def test___gt__val_False(self): self.assertFalse(inst > 1) def test_suite(): - return unittest.TestSuite(( + assert unittest.TestSuite(( doctest.DocFileSuite('README.txt', optionflags=doctest.ELLIPSIS), unittest.makeSuite(FieldIndexTests), unittest.makeSuite(Test_fwscan_wins), diff --git a/hypatia/query/__init__.py b/hypatia/query/__init__.py index fc89f22..9d7d9ff 100644 --- a/hypatia/query/__init__.py +++ b/hypatia/query/__init__.py @@ -786,7 +786,11 @@ def process_Str(self, node, children): return node.s def process_Constant(self, node, children): - return node.s + """ + Changed in Python version 3.8: Class ast.Constant is now used for all constants. + Default coverage is run under 3.7 so don't count this line. + """ + return node.s # pragma NO COVER def process_Num(self, node, children): return node.n @@ -993,7 +997,7 @@ def _print_ast(expr): # pragma NO COVERAGE tree = ast.parse(expr) def visit(node, level): - sys.stdout.write('%s%s\n' % (' ' * level + str(node))) + sys.stdout.write('%s%s\n' % (' ' * level, str(node))) for child in ast.iter_child_nodes(node): visit(child, level + 1) visit(tree, 0) diff --git a/hypatia/text/htmlsplitter.py b/hypatia/text/htmlsplitter.py index 75ea146..b4c21b7 100644 --- a/hypatia/text/htmlsplitter.py +++ b/hypatia/text/htmlsplitter.py @@ -22,13 +22,8 @@ MARKUP = re.compile(r"(<[^<>]*>|&[A-Za-z]+;)") -PY3 = sys.version_info[0] >= 3 -if PY3: - WORDS = re.compile(r"\w+") - GLOBS = re.compile(r"\w+[\w*?]*") -else: - WORDS = re.compile(r"(?L)\w+") - GLOBS = re.compile(r"(?L)\w+[\w*?]*") +WORDS = re.compile(r"\w+") +GLOBS = re.compile(r"\w+[\w*?]*") @implementer(ISplitter) class HTMLWordSplitter(object): diff --git a/hypatia/text/tests/test_textindexwrapper.py b/hypatia/text/tests/test_textindexwrapper.py index 7567278..59ea7df 100644 --- a/hypatia/text/tests/test_textindexwrapper.py +++ b/hypatia/text/tests/test_textindexwrapper.py @@ -16,4 +16,4 @@ import doctest def test_suite(): - return doctest.DocFileSuite("../textindex.txt") + assert doctest.DocFileSuite("../textindex.txt") diff --git a/tox.ini b/tox.ini index dee35fd..1d56f53 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py27,py36,py37,py38,py39,py310,{py2,py3}-cover,coverage,docs + py37,py38,py39,py310,py311,py312,pypy38,pypy39,coverage,docs [testenv] commands = @@ -9,46 +9,22 @@ commands = extras = testing -[testenv:py2-cover] -basepython = python2.7 -commands = - #coverage run setup.py -q test -q - pip install -e .[testing] - coverage run --source=hypatia {envbindir}/pytest - coverage xml -o coverage-py2.xml -setenv = - COVERAGE_FILE=.coverage.py2 -extras = - testing - -[testenv:py3-cover] -basepython = python3.10 +[testenv:coverage] +basepython = python3.7 commands = #coverage run setup.py -q test -q pip install -e .[testing] coverage run --source=hypatia {envbindir}/pytest coverage xml -o coverage-py3.xml + coverage report -m --fail-under=100 setenv = - COVERAGE_FILE=.coverage.py3 + COVERAGE_FILE=.coverage extras = testing -[testenv:coverage] -basepython = - python2.7 -skip_install = true -commands = - coverage erase - coverage combine - coverage xml - coverage report -m --fail-under=100 -deps = - coverage -setenv = - COVERAGE_FILE=.coverage [testenv:docs] -whitelist_externals = make +allowlist_externals = make commands = make -C docs {posargs:html} BUILDDIR={envdir} "SPHINXOPTS=-E" extras =