Skip to content

Commit

Permalink
presents test runner, more test coverage and entirely rethinked docum…
Browse files Browse the repository at this point in the history
…entation
  • Loading branch information
gabrielfalcao committed Jan 15, 2024
1 parent 1b0b473 commit b65631f
Show file tree
Hide file tree
Showing 119 changed files with 12,433 additions and 4,983 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: Sure Tests
on:
push:
Expand All @@ -24,8 +23,14 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Run Tests
- name: Install Python
uses: gabrielfalcao/pyenv-action@v18
with:
default: "${{ matrix.python }}"
command: make dependencies tests
command: make dependencies

- name: Test with PyTest
run: make dependencies tests

- name: Self/Auto Test
run: make dependencies run
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# rust
target/

# python bytecode
*.pyc
__pycache__
Expand All @@ -7,7 +10,9 @@ docs/_build
build/
dist/
*.egg-info/
sure-*.tar.gz
-*.tar.gz
.venv/
/.python-version

# temporary test files and dirs
.coverage
Expand All @@ -17,5 +22,3 @@ sure-*.tar.gz
*.sublime-project
*.sublime-workspace
*.swp
.venv/
/.python-version
3 changes: 1 addition & 2 deletions .release
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ declare current_version
declare sure


current_version="$(grep -E version ./sure/version.py | sed 's,version *= *.\(\([0-9]*[.]*\)\{3\,4\}\).,\1,g')"
current_version="$(grep -E version ./sure/version.py | sed 's,version *= *.\(\([0-9]*[.]*\)\{3\,4\}\(dev\|a\|b\)[0-9]*\).,\1,g')"
echo -en "The current version is \033[1;33m$current_version\033[0m, type a new one\n\033[1;32mnew version:\033[0m "
read -r newversion

Expand All @@ -14,7 +14,6 @@ function find_files () {
for name in $(find . -name 'README.rst' -or -name version.py -or -name conf.py | grep -v '\(\.venv\|build\)[/]'); do
echo "${name}"
done

}

function update_files (){
Expand Down
87 changes: 2 additions & 85 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,86 +1,3 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
# Changelog

## [v2.0.0]
### Fixed
- No longer patch the builtin `dir()` function, which fixes pytest in some cases such as projects using gevent.

## [v1.4.11]
### Fixed
- Reading the version dinamically was causing import errors that caused error when installing package. Refs #144

## [v1.4.7]
### Fixed
- Remove wrong parens for format call. Refs #139

## [v1.4.6]
### Added
- Support and test against PyPy 3

### Fixed
- Fix safe representation in exception messages for bytes and unicode objects. Refs #136

## [v1.4.5]
### Fixed
- Correctly escape special character for `str.format()` for assertion messages. Refs #134

## [v1.4.4]

*Nothing to mention here.*

## [v1.4.3]
### Fixed
- Bug in setup.py that would break in python > 2

## [v1.4.2]
### Added
- `ensure` context manager to provide custom assertion messages. Refs #125

## [v1.4.1]
### Added
- Python 3.6 support
- Python 3.7-dev support (allowed to fail)

### Fixed
- Do not overwrite existing class and instance attributes with sure properties (when. should, ...). Refs #127, #129
- Fix patched built-in `dir()` method. Refs #124, #128

## [v1.4.0]
### Added
- anything object which is accessible with `sure.anything`
- interface to extend sure. Refs #31

### Removed
- Last traces of Python 2.6 support

### Fixed
- Allow overwriting of monkey-patched properties by sure. Refs #19
- Assertions for raises

## [v1.3.0]
### Added
- Python 3.3, 3.4 and 3.5 support
- pypy support
- Support comparison of OrderedDict. Refs #55

### Fixed
- `contain` assertion. Refs #104


## No previous changelog history.

Please see `git log`

[Unreleased]: https://github.com/gabrielfalcao/sure/compare/v1.4.7...HEAD
[v1.4.7]: https://github.com/gabrielfalcao/sure/compare/1.4.6...v1.4.7
[v1.4.6]: https://github.com/gabrielfalcao/sure/compare/1.4.5...v1.4.6
[v1.4.5]: https://github.com/gabrielfalcao/sure/compare/1.4.4...v1.4.5
[v1.4.4]: https://github.com/gabrielfalcao/sure/compare/1.4.3...v1.4.4
[v1.4.3]: https://github.com/gabrielfalcao/sure/compare/1.4.2...v1.4.3
[v1.4.2]: https://github.com/gabrielfalcao/sure/compare/1.4.1...v1.4.2
[v1.4.1]: https://github.com/gabrielfalcao/sure/compare/1.4.0...v1.4.1
[v1.4.0]: https://github.com/gabrielfalcao/sure/compare/1.3.0...v1.4.0
[v1.3.0]: https://github.com/gabrielfalcao/sure/compare/1.2.9...v1.3.0
[1.2.9]: https://github.com/gabrielfalcao/sure/compare/1.2.5...1.2.9
[1.2.5]: https://github.com/gabrielfalcao/sure/compare/1.2.4...1.2.5
The changelog of the Sure project has been moved to the documentation page: [https://sure.readthedocs.io](https://sure.readthedocs.io)
76 changes: 51 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ GIT_ROOT := $(shell dirname $(MAKEFILE_PATH))
VENV_ROOT := $(GIT_ROOT)/.venv

PACKAGE_NAME := sure
MAIN_CLI_NAME := sure
LIBEXEC_NAME := sure
REQUIREMENTS_FILE := development.txt

PACKAGE_PATH := $(GIT_ROOT)/$(PACKAGE_NAME)
REQUIREMENTS_PATH := $(GIT_ROOT)/$(REQUIREMENTS_FILE)
MAIN_CLI_PATH := $(VENV_ROOT)/bin/$(MAIN_CLI_NAME)
LIBEXEC_PATH := $(VENV_ROOT)/bin/$(LIBEXEC_NAME)
export VENV ?= $(VENV_ROOT)

OSNAME := $(shell uname)
Expand All @@ -17,15 +17,18 @@ OPEN_COMMAND := gnome-open
else
OPEN_COMMAND := open
endif
export SURE_NO_COLORS := true
export SURE_NO_COLORS := true
export SURE_LOG_FILE := $(GIT_ROOT)/sure-$(date +"%Y-%m-%d-%H:%M:%S").log
export PYTHONPATH := $(GIT_ROOT)
AUTO_STYLE_TARGETS := sure/runtime.py sure/runner.py sure/meta.py sure/meta.py sure/reporter.py sure/reporters

######################################################################
# Phony targets (only exist for typing convenience and don't represent
# real paths as Makefile expects)
######################################################################

# default target when running `make` without arguments
all: | $(MAIN_CLI_PATH)
all: | $(LIBEXEC_PATH)

# creates virtualenv
venv: | $(VENV)
Expand All @@ -34,48 +37,59 @@ venv: | $(VENV)
develop: | $(VENV)/bin/python $(VENV)/bin/pip

# installs the requirements and the package dependencies
setup: | $(MAIN_CLI_PATH)
setup: | $(LIBEXEC_PATH)

# Convenience target to ensure that the venv exists and all
# requirements are installed
dependencies:
@rm -f $(MAIN_CLI_PATH) # remove MAIN_CLI_PATH to trigger pip install
dependencies: $(VENV)/bin/pytest
@rm -f $(LIBEXEC_PATH) # remove LIBEXEC_PATH to trigger pip install
$(MAKE) develop setup

docs:
clean-docs:
@rm -rf docs/build

html-docs: clean-docs
@(cd docs && make html)

docs: html-docs
$(OPEN_COMMAND) docs/build/html/index.html

test tests: clean | $(VENV)/bin/pytest # $(VENV)/bin/nosetests # @$(VENV)/bin/nosetests --rednose --immediate -vv --with-coverage --cover-package=sure
@$(VENV)/bin/pytest -vv --cov=sure
test tests:
@$(VENV)/bin/pytest --cov=sure tests

# run main command-line tool
run: | $(MAIN_CLI_PATH)
@$(MAIN_CLI_PATH) --help
# runs main command-line tool
run: | $(LIBEXEC_PATH)
$(LIBEXEC_PATH) --reap-warnings tests/crashes
$(LIBEXEC_PATH) --reap-warnings --special-syntax --with-coverage --cover-branches --cover-module=sure.core --cover-module=sure tests/runner
$(LIBEXEC_PATH) --reap-warnings --special-syntax --with-coverage --cover-branches --cover-module=sure --immediate --cover-module=sure --ignore tests/crashes tests

# Pushes release of this package to pypi
push-release: dist # pushes distribution tarballs of the current version
$(VENV)/bin/twine upload dist/*.tar.gz

# Prepares release of this package prior to pushing to pypi
build-release:
$(VENV)/bin/python setup.py build sdist
$(VENV)/bin/twine check dist/*.tar.gz

# Convenience target that runs all tests then builds and pushes a release to pypi
release: tests
@./.release
$(MAKE) build-release
$(MAKE) push-release

# Convenience target to delete the virtualenv
clean:
@rm -rf .coverage

# Convenience target to format code with black with PEP8's default
# 80 character limit per line
flake8: | $(VENV)/bin/flake8
@$(VENV)/bin/flake8 --statistics --max-complexity 17 --exclude=$(VENV) $(AUTO_STYLE_TARGETS)

black: | $(VENV)/bin/black
@$(VENV)/bin/black -l 80 $(PACKAGE_PATH) tests
@$(VENV)/bin/black -l 80 $(AUTO_STYLE_TARGETS)

isort: | $(VENV)/bin/isort
@$(VENV)/bin/isort --overwrite-in-place --profile=black --ls --srx --cs --ca -n --ot --tc --color --star-first --virtual-env $(VENV) --py auto $(AUTO_STYLE_TARGETS)


autostyle: run isort black flake8


##############################################################
# Real targets (only run target if its file has been "made" by
Expand All @@ -97,11 +111,17 @@ $(VENV)/bin/python $(VENV)/bin/pip: # installs latest pip
$(VENV)/bin/black: | $(VENV)/bin/pip
$(VENV)/bin/pip install -U black

$(VENV)/bin/isort: | $(VENV)/bin/pip
$(VENV)/bin/pip install -U isort

$(VENV)/bin/flake8: | $(VENV)/bin/pip
$(VENV)/bin/pip install -U flake8

# installs this package in "edit" mode after ensuring its requirements are installed

$(VENV)/bin/nosetests $(VENV)/bin/pytest $(MAIN_CLI_PATH): | $(VENV) $(VENV)/bin/pip $(VENV)/bin/python $(REQUIREMENTS_PATH)
install $(VENV)/bin/pytest $(LIBEXEC_PATH): | $(VENV) $(VENV)/bin/pip $(VENV)/bin/python $(REQUIREMENTS_PATH)
$(VENV)/bin/pip install -r $(REQUIREMENTS_PATH)
$(VENV)/bin/pip install -e .
$(VENV)/bin/pip install .

# ensure that REQUIREMENTS_PATH exists
$(REQUIREMENTS_PATH):
Expand All @@ -120,15 +140,21 @@ $(REQUIREMENTS_PATH):

.PHONY: \
all \
autostyle \
black \
build-release \
clean \
clean-docs \
dependencies \
develop \
docs \
flake8 \
html-docs \
install \
isort \
push-release \
release \
setup \
run \
setup \
test \
tests \
docs
tests

0 comments on commit b65631f

Please sign in to comment.