Skip to content

Commit

Permalink
Merge pull request #8 from andreif/feature/test-for-35-and-36
Browse files Browse the repository at this point in the history
Test for Python 2.6, 3.5 and 3.6.
  • Loading branch information
lundberg committed Dec 12, 2017
2 parents f9aba52 + 1230d23 commit 6471650
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,7 +1,9 @@
*.pyc
*.egg
*.egg-info
*.eggs
.coverage
.coverage.*
.idea
.DS_Store
.tox
Expand Down
49 changes: 37 additions & 12 deletions .travis.yml
@@ -1,20 +1,45 @@
language: python
sudo: false

python:
- "2.7"
- "3.3"
- "3.4"
python: 3.5

env:
# NOTE: On Travis web page define private STASH_URL, STASH_TOKEN, STASH_SECRET.
global:
- STASH_BOX=$TRAVIS_REPO_SLUG:$TRAVIS_BUILD_NUMBER:$STASH_SECRET
matrix:
- TOXENV=py27
- TOXENV=py34
- TOXENV=py35
- TOXENV=lint
- TOXENV=coverage

matrix:
include:
- env: TOXENV=py26
python: 2.6
- env: TOXENV=py33
python: 3.3
- env: TOXENV=py36
python: 3.6

install:
- if [[ "${TRAVIS_PYTHON_VERSION}" == "2.6" ]]; then pip install importlib unittest2 "markdown<=2.4"; fi
- pip install flake8 python-coveralls
- pip install -e .
- pip install "file://`pwd`#egg=content-io[tests]"
- pip install --upgrade pip
- pip install tox stasher

script:
- make flake8
- coverage run --source cio runtests.py
- coverage report
- if [[ $TOXENV =~ coverage ]] && [ -n "$STASH_SECRET" ]; then
stash pull $STASH_BOX -wc $(TOXENV= tox -l | wc -l);
fi
- if [[ ! $TOXENV =~ coverage ]] || [ -n "$STASH_SECRET" ]; then
tox;
fi
- if [[ $TOXENV =~ py ]] && [ -n "$STASH_SECRET" ]; then
stash push $STASH_BOX $(ls .coverage.*);
fi

after_success:
- coveralls
- if [[ $TOXENV =~ coverage ]]; then
pip install --quiet python-coveralls;
coveralls --ignore-errors;
fi
23 changes: 20 additions & 3 deletions Makefile
@@ -1,18 +1,35 @@
.DEFAULT_GOAL := help

.PHONY: help # shows available commands
help:
@echo "\nAvailable commands:\n\n $(shell sed -n 's/^.PHONY:\(.*\)/ *\1\\n/p' Makefile)"

.PHONY: test
test:
python setup.py test
coverage run setup.py test

.PHONY: test_all # runs tests using detox, combines coverage and reports it
test_all:
detox
make coverage

flake8:
.PHONY: lint
lint:
flake8 cio

.PHONY: install
install:
python setup.py install

.PHONY: develop
develop:
python setup.py develop

.PHONY: coverage
coverage:
coverage run --source cio setup.py test && \
coverage combine || true
coverage report

.PHONY: clean
clean:
rm -rf .tox/ dist/ *.egg *.egg-info .coverage
16 changes: 4 additions & 12 deletions cio/plugins/md.py
@@ -1,21 +1,13 @@
from __future__ import unicode_literals

import logging

from .txt import TextPlugin
from .. import PY26


class MarkdownPlugin(TextPlugin):

ext = 'md'

def render(self, data):
if PY26:
logging.warning('Markdown is not supported for Python 2.6')
return data
else:
import markdown
if data:
extensions = self.settings.get('EXTENSIONS', [])
return markdown.markdown(data, extensions=extensions)
import markdown
if data:
extensions = self.settings.get('EXTENSIONS', [])
return markdown.markdown(data, extensions=extensions)
20 changes: 18 additions & 2 deletions setup.cfg
@@ -1,5 +1,21 @@
[flake8]
ignore = E501,E731
max-line-length = 100
ignore = E731
max-line-length = 120
exclude = .tox,.git,docs
max-complexity = 12

[coverage:run]
source = cio
branch = True
parallel = True

[coverage:report]
fail_under = 98
skip_covered = True
show_missing = True

# Regex expressions for lines excluded from report
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
raise NotImplementedError
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -21,9 +21,9 @@
version=version,
description='Send content through a highly configurable pipeline including cache, plugin and storage pipes',
long_description=(
'.. image:: https://travis-ci.org/5monkeys/content-io.png?branch=master\n'
'.. image:: https://travis-ci.org/5monkeys/content-io.svg?branch=master\n'
' :target: https://travis-ci.org/5monkeys/content-io\n'
'.. image:: https://coveralls.io/repos/5monkeys/content-io/badge.png?branch=master\n'
'.. image:: https://coveralls.io/repos/5monkeys/content-io/badge.svg?branch=master\n'
' :target: https://coveralls.io/r/5monkeys/content-io?branch=master\n\n'
),
author='Jonas Lundberg',
Expand All @@ -48,6 +48,8 @@
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
],
Expand Down
4 changes: 0 additions & 4 deletions tests/test_plugins.py
Expand Up @@ -64,7 +64,3 @@ def test_settings(self):
def test_markdown(self):
markdown = plugins.get('md')
self.assertEqual(markdown.render('# Title'), '<h1>Title</h1>')

md_module.PY26 = True
self.assertEqual(markdown.render('# Title'), '# Title')
md_module.PY26 = cio.PY26
24 changes: 19 additions & 5 deletions tox.ini
Expand Up @@ -4,12 +4,26 @@
# and then run "tox" from this directory.

[tox]
envlist = py26, py27, py33, py34
envlist = py26, py27, py33, py34, py35, py36

[testenv]
commands = {envpython} setup.py test
passenv = COVERAGE_FILE
whitelist_externals = make
commands = make test
deps = six
coverage
py26: markdown<=2.4
wheel<0.30

[testenv:py26]
deps = {[testenv]deps}
markdown<=2.4
[testenv:coverage]
basepython = python3.5
skip_install = true
passenv = COVERAGE_FILE
commands = make coverage
deps = coverage

[testenv:lint]
basepython = python3.5
skip_install = true
commands = make lint
deps = flake8

0 comments on commit 6471650

Please sign in to comment.