Skip to content

Tests for python up to 3.6 and pytest up to 4.0 #19

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

Closed
wants to merge 1 commit into from
Closed
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
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# pyenv
.python-version

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
124 changes: 110 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,115 @@
language: python
python: 2.7
env:
- TOX_ENV=py27-pytest27
- TOX_ENV=py27-pytest28
- TOX_ENV=py27-pytest32
- TOX_ENV=py27-pytest33
- TOX_ENV=py34-pytest27
- TOX_ENV=py34-pytest28
- TOX_ENV=py34-pytest32
- TOX_ENV=py34-pytest33
# - TOX_ENV=py35-pytest27
# - TOX_ENV=py35-pytest28
# - TOX_ENV=py35-pytest32
# - TOX_ENV=py35-pytest33

matrix:
include:
- python: 2.7
env: TOX_ENV=py27-pytest27
- python: 2.7
env: TOX_ENV=py27-pytest28
- python: 2.7
env: TOX_ENV=py27-pytest29
- python: 2.7
env: TOX_ENV=py27-pytest32
- python: 2.7
env: TOX_ENV=py27-pytest33
- python: 2.7
env: TOX_ENV=py27-pytest34
- python: 2.7
env: TOX_ENV=py27-pytest35
- python: 2.7
env: TOX_ENV=py27-pytest36
- python: 2.7
env: TOX_ENV=py27-pytest37
- python: 2.7
env: TOX_ENV=py27-pytest38
- python: 2.7
env: TOX_ENV=py27-pytest39
- python: 2.7
env: TOX_ENV=py27-pytest310
- python: 2.7
env: TOX_ENV=py27-pytest40
- python: 3.4
env: TOX_ENV=py34-pytest27
- python: 3.4
env: TOX_ENV=py34-pytest28
- python: 3.4
env: TOX_ENV=py34-pytest29
- python: 3.4
env: TOX_ENV=py34-pytest32
- python: 3.4
env: TOX_ENV=py34-pytest33
- python: 3.4
env: TOX_ENV=py34-pytest34
- python: 3.4
env: TOX_ENV=py34-pytest35
- python: 3.4
env: TOX_ENV=py34-pytest36
- python: 3.4
env: TOX_ENV=py34-pytest37
- python: 3.4
env: TOX_ENV=py34-pytest38
- python: 3.4
env: TOX_ENV=py34-pytest39
- python: 3.4
env: TOX_ENV=py34-pytest310
- python: 3.4
env: TOX_ENV=py34-pytest40
- python: 3.5
env: TOX_ENV=py35-pytest27
- python: 3.5
env: TOX_ENV=py35-pytest28
- python: 3.5
env: TOX_ENV=py35-pytest29
- python: 3.5
env: TOX_ENV=py35-pytest32
- python: 3.5
env: TOX_ENV=py35-pytest33
- python: 3.5
env: TOX_ENV=py35-pytest34
- python: 3.5
env: TOX_ENV=py35-pytest35
- python: 3.5
env: TOX_ENV=py35-pytest36
- python: 3.5
env: TOX_ENV=py35-pytest37
- python: 3.5
env: TOX_ENV=py35-pytest38
- python: 3.5
env: TOX_ENV=py35-pytest39
- python: 3.5
env: TOX_ENV=py35-pytest310
- python: 3.5
env: TOX_ENV=py35-pytest40
- python: 3.6
env: TOX_ENV=py36-pytest27
- python: 3.6
env: TOX_ENV=py36-pytest28
- python: 3.6
env: TOX_ENV=py36-pytest29
- python: 3.6
env: TOX_ENV=py36-pytest32
- python: 3.6
env: TOX_ENV=py36-pytest33
- python: 3.6
env: TOX_ENV=py36-pytest34
- python: 3.6
env: TOX_ENV=py36-pytest35
- python: 3.6
env: TOX_ENV=py36-pytest36
- python: 3.6
env: TOX_ENV=py36-pytest37
- python: 3.6
env: TOX_ENV=py36-pytest38
- python: 3.6
env: TOX_ENV=py36-pytest39
- python: 3.6
env: TOX_ENV=py36-pytest310
- python: 3.6
env: TOX_ENV=py36-pytest40

install:
- pip install tox

script:
- tox -e $TOX_ENV

17 changes: 9 additions & 8 deletions test/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ def test_something():
"""))

result = testdir.runpytest('--collectonly')
trimmed_result = list(map(lambda outline: outline.strip(), result.outlines))
expected_lines = [
"collected 4 items",
" <DescribeBlock 'describe_something'>",
" <Function 'is_foo'>",
" <Function 'can_bar'>",
" <DescribeBlock 'describe_something_else'>",
" <DescribeBlock 'describe_nested'>",
" <Function 'a_test'>",
" <Function 'test_something'>",
"<DescribeBlock 'describe_something'>",
"<Function 'is_foo'>",
"<Function 'can_bar'>",
"<DescribeBlock 'describe_something_else'>",
"<DescribeBlock 'describe_nested'>",
"<Function 'a_test'>",
"<Function 'test_something'>",
]
for line in expected_lines:
assert line in result.outlines
assert line in trimmed_result


def test_describe_evaluated_once(testdir):
Expand Down
28 changes: 9 additions & 19 deletions test/test_custom_prefix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import py
import re

pytest_plugins = 'pytester'

Expand All @@ -8,19 +9,6 @@
"""


def _collect_result(result):
lines = result.stdout.lines

# discard last line if empty
if lines[-1] == '':
lines = lines[:-1]

# workaround for older versions of pytest not pluralizing correctly
lines = [l.replace(' 1 items', ' 1 item') for l in lines]

return lines[-7:-2]


def test_collect_custom_prefix(testdir):
testdir.makeini(ini)

Expand All @@ -34,10 +22,12 @@ def passes():

result = testdir.runpytest('--collectonly')
print(result.outlines)
assert _collect_result(result) == [
"collected 1 item",
"<Module 'a_dir/test_a.py'>",
" <DescribeBlock 'foo_scope'>",
" <DescribeBlock 'bar_context'>",
" <Function 'passes'>",
expected_lines = [
re.compile("collected 1 item(s)?"),
re.compile("\s*<Module '(a_dir/)?test_a.py'>"),
re.compile("\s*<DescribeBlock 'foo_scope'>"),
re.compile("\s*<DescribeBlock 'bar_context'>"),
re.compile("\s*<Function 'passes'>"),
]
for line in expected_lines:
assert any([line.match(r) is not None for r in result.outlines])
11 changes: 10 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
[tox]
envlist = {py27,py34,py35}-pytest{27,28}
envlist = {py27,py34,py35,py36}-pytest{27,28,29,32,33,34,35,36,37,38,39,310,40}

[testenv]
basepython =
py27: python2.7
py34: python3.4
py35: python3.5
py36: python3.6
deps =
pytest27: pytest>=2.7,<2.8
pytest28: pytest>=2.8,<2.9
pytest29: pytest>=2.9,<2.10
pytest32: pytest>=3.2,<3.3
pytest33: pytest>=3.3,<3.4
pytest34: pytest>=3.4,<3.5
pytest35: pytest>=3.5,<3.6
pytest36: pytest>=3.6,<3.7
pytest37: pytest>=3.7,<3.8
pytest38: pytest>=3.8,<3.9
pytest39: pytest>=3.9,<3.10
pytest310: pytest>=3.10,<4.0
pytest40: pytest>=4.0,<4.1
commands = py.test -rw