Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidying up, and replace nose with pytest #1289

Merged
merged 18 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,66 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10.0-beta.3"]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 9999
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and prepare tests
run: |
set -x
python -m pip install --upgrade pip
python -m pip install --upgrade pip setuptools wheel
python --version; git --version
git submodule update --init --recursive
git fetch --tags


pip install -r requirements.txt
pip install -r test-requirements.txt
TRAVIS=yes ./init-tests-after-clone.sh

git config --global user.email "[email protected]"
git config --global user.name "Travis Runner"
# If we rewrite the user's config by accident, we will mess it up
# and cause subsequent tests to fail
cat test/fixtures/.gitconfig >> ~/.gitconfig

- name: Lint with flake8

run: |
set -x
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 --ignore=W293,E265,E266,W503,W504,E731 --count --show-source --statistics
flake8 --ignore=W293,E265,E266,W503,W504,E704,E731 --count --show-source --statistics

- name: Check types with mypy
run: |
set -x
pip install tox
tox -e type
pip install mypy
mypy -p git

- name: Test with pytest
run: |
set -x
pip install -r requirements-dev.txt
pytest --cov --cov-report=term
# pytest settings in tox.ini[pytest]
continue-on-error: false

- name: Documentation
run: |
set -x
pip install -r doc/requirements.txt
make -C doc html

# - name: Test with nose
# run: |
# set -x
# pip install nose
# nosetests -v --with-coverage
# continue-on-error: false


7 changes: 7 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-r requirements.txt
-r test-requirements.txt

pytest
pytest-cov
pytest-sugar
pytest-icdiff
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python
from __future__ import print_function
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
from ez_setup import use_setuptools # type: ignore[Pylance]
use_setuptools()
from setuptools import setup, find_packages

from distutils.command.build_py import build_py as _build_py
from setuptools.command.build_py import build_py as _build_py
from setuptools.command.sdist import sdist as _sdist
import fnmatch
import os
Expand Down Expand Up @@ -95,7 +94,6 @@ def build_py_modules(basedir, excludes=[]):
license="BSD",
url="https://github.com/gitpython-developers/GitPython",
packages=find_packages(exclude=("test.*")),
# package_data={'git': ['**/*.pyi', 'py.typed']},
include_package_data=True,
py_modules=build_py_modules("./git", excludes=["git.ext.*"]),
package_dir={'git': 'git'},
Expand Down
4 changes: 3 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ coverage
flake8
tox
virtualenv
nose
pytest
pytest-cov
pytest-sugar
gitdb>=4.0.1,<5
typing-extensions>=3.7.4.3;python_version<"3.10"
28 changes: 26 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ commands = coverage run --omit="git/test/*" -m unittest --buffer {posargs}
coverage report

[testenv:flake8]
commands = flake8 --ignore=W293,E265,E266,W503,W504,E731 {posargs}
commands = flake8 --ignore=W293,E265,E266,W503,W504,E704,E731 {posargs}

[testenv:type]
description = type check ourselves
Expand All @@ -32,6 +32,30 @@ commands = {posargs}
# E731 = do not assign a lambda expression, use a def
# W293 = Blank line contains whitespace
# W504 = Line break after operator
ignore = E265,W293,E266,E731, W504
# E707 = multiple statements in one line - used for @overloads
ignore = E265,W293,E266,E731,E704, W504
max-line-length = 120
exclude = .tox,.venv,build,dist,doc,git/ext/

[pytest]
python_files =
test_*.py

# space seperated list of paths from root e.g test tests doc/testing
testpaths = test

# --cov coverage
# --cov-report term # send report to terminal term-missing -> terminal with line numbers html xml
# --cov-report term-missing # to terminal with line numbers
# --cov-report html:path # html file at path
# --maxfail # number of errors before giving up
# -disable-warnings # Disable pytest warnings (not codebase warnings)
#-rf # increased reporting of failures
# -rE # increased reporting of errors
# --ignore-glob=**/gitdb/* # ignore glob paths
addopts = --cov=git --cov-report=term --maxfail=50 -rf --verbosity=0 --disable-warnings

# ignore::WarningType # ignores those warnings
# error # turn any unignored warning into errors
filterwarnings =
ignore::DeprecationWarning