Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from sgissinger/master
- Loading branch information
Showing
19 changed files
with
878 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Python CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy3] | ||
experimental: [false] | ||
include: | ||
- os: ubuntu-latest | ||
python-version: pypy2 | ||
experimental: false | ||
- os: ubuntu-latest | ||
python-version: 3.10-dev | ||
experimental: true | ||
|
||
runs-on: ${{ matrix.os }} | ||
continue-on-error: ${{ matrix.experimental }} | ||
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
if: "!endsWith(matrix.python-version, '-dev')" | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: deadsnakes/action@v2.0.0 | ||
if: endsWith(matrix.python-version, '-dev') | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
env: | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements-dev.txt | ||
pip install -r requirements.txt | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --max-complexity=10 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest -s -v --tb=native --capture=sys --cov grappa --cov-report term-missing tests | ||
- name: Coverage | ||
run: | | ||
coverage run --source grappa -m py.test | ||
coverage report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
# -*- coding: utf-8 -*- | ||
from ..decorators import mock_implementation_validator | ||
from ..operator import Operator | ||
|
||
|
||
class BeenCalledOperator(Operator): | ||
""" | ||
Asserts if a given mock subject have been called at least once. | ||
Warning:: | ||
Piping style assertions is not yet supported. | ||
Example:: | ||
# Should style | ||
should(mock).have.been_called | ||
# Should style - negation form | ||
should(mock).have_not.been_called | ||
# Expect style | ||
expect(mock).to.have.been_called | ||
# Expect style - negation form | ||
expect(mock).to.have_not.been_called | ||
expect(mock).to_not.have.been_called | ||
""" | ||
|
||
# Is the operator a keyword | ||
kind = Operator.Type.ACCESSOR | ||
|
||
# Disable diff report | ||
show_diff = False | ||
|
||
# Operator keywords | ||
operators = ('been_called',) | ||
|
||
# Error message templates | ||
expected_message = Operator.Dsl.Message( | ||
'a mock that has been called at least once', | ||
'a mock that has not been called', | ||
) | ||
|
||
# Subject message template | ||
subject_message = Operator.Dsl.Message( | ||
'a mock that has not been called', | ||
'a mock that has been called at least once', | ||
) | ||
|
||
@mock_implementation_validator | ||
def match(self, subject): | ||
return subject.called | ||
|
||
|
||
class BeenCalledOnceOperator(Operator): | ||
""" | ||
Asserts if a given mock subject have been called once. | ||
Warning:: | ||
Piping style assertions is not yet supported. | ||
Example:: | ||
# Should style | ||
should(mock).have.been_called_once | ||
# Should style - negation form | ||
should(mock).have_not.been_called_once | ||
# Expect style | ||
expect(mock).to.have.been_called_once | ||
# Expect style - negation form | ||
expect(mock).to.have_not.been_called_once | ||
expect(mock).to_not.have.been_called_once | ||
""" | ||
|
||
# Is the operator a keyword | ||
kind = Operator.Type.ACCESSOR | ||
|
||
# Disable diff report | ||
show_diff = False | ||
|
||
# Operator keywords | ||
operators = ('been_called_once',) | ||
|
||
# Error message templates | ||
expected_message = Operator.Dsl.Message( | ||
'a mock that has been called once', | ||
'a mock that has not been called once', | ||
) | ||
|
||
# Subject message template | ||
subject_message = Operator.Dsl.Message( | ||
'a mock that has been called {call_count} time(s)', | ||
'a mock that has been called once', | ||
) | ||
|
||
@mock_implementation_validator | ||
def match(self, subject): | ||
return subject.call_count == 1 | ||
|
||
|
||
class BeenCalledTimesOperator(Operator): | ||
""" | ||
Asserts if a given mock subject have been called n times. | ||
Warning:: | ||
Piping style assertions is not yet supported. | ||
Example:: | ||
# Should style | ||
should(mock).have.been_called_times(3) | ||
# Should style - negation form | ||
should(mock).have_not.been_called_times(3) | ||
# Expect style | ||
expect(mock).to.have.been_called_times(0) | ||
# Expect style - negation form | ||
expect(mock).to.have_not.been_called_times(1) | ||
expect(mock).to_not.have.been_called_times(3) | ||
""" | ||
|
||
# Is the operator a keyword | ||
kind = Operator.Type.MATCHER | ||
|
||
# Disable diff report | ||
show_diff = True | ||
|
||
# Operator keywords | ||
operators = ('been_called_times',) | ||
|
||
# Error message templates | ||
expected_message = Operator.Dsl.Message( | ||
'a mock that has been called {value} times', | ||
'a mock that has not been called {value} times', | ||
) | ||
|
||
subject_message = Operator.Dsl.Message( | ||
'a mock that has been called {call_count} times', | ||
'a mock that has not been called {call_count} times', | ||
) | ||
|
||
@mock_implementation_validator | ||
def match(self, subject, expected): | ||
return subject.call_count == expected |
Oops, something went wrong.