Skip to content

Commit

Permalink
Merge pull request #1433 from scrapy/codecov
Browse files Browse the repository at this point in the history
Coverage and reports at codecov.io and coveralls.io
  • Loading branch information
kmike committed Aug 14, 2015
2 parents 12bebb6 + 27077d2 commit 9adb5c3
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 5 deletions.
18 changes: 17 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
[run]
branch = true
include = scrapy/*
omit = scrapy/xlib*,scrapy/tests*
omit =
tests/*
scrapy/xlib/*
scrapy/conf.py
scrapy/stats.py
scrapy/project.py
scrapy/utils/decorator.py
scrapy/statscol.py
scrapy/squeue.py
scrapy/log.py
scrapy/dupefilter.py
scrapy/command.py
scrapy/linkextractor.py
scrapy/spider.py
scrapy/contrib/*
scrapy/contrib_exp/*
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ env:
- TOXENV=py33
- TOXENV=docs
install:
- pip install -U tox twine wheel
- pip install -U tox twine wheel codecov coveralls
script: tox
after_success:
- codecov
- coveralls
notifications:
irc:
use_notice: true
Expand Down
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Scrapy
:target: https://github.com/scrapy/scrapy/wiki/Python-3-Porting
:alt: Python 3 Porting Status

.. image:: https://img.shields.io/codecov/c/github/scrapy/scrapy/master.svg
:target: http://codecov.io/github/scrapy/scrapy?branch=master
:alt: Coverage report


Overview
========
Expand Down
7 changes: 7 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ To run a specific test (say ``tests/test_loader.py``) use:

``tox -- tests/test_loader.py``

To see coverage report install `coverage`_ (``pip install coverage``) and run:

``coverage report``

see output of ``coverage --help`` for more options like html or xml report.

.. _coverage: https://pypi.python.org/pypi/coverage

Writing tests
-------------
Expand Down
8 changes: 8 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
os.environ['https_proxy'] = ''
os.environ['ftp_proxy'] = ''

# Absolutize paths to coverage config and output file because tests that
# spawn subprocesses also changes current working directory.
_sourceroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if 'COV_CORE_CONFIG' in os.environ:
os.environ['COVERAGE_FILE'] = os.path.join(_sourceroot, '.coverage')
os.environ['COV_CORE_CONFIG'] = os.path.join(_sourceroot,
os.environ['COV_CORE_CONFIG'])

try:
import unittest.mock as mock
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions tests/requirements-py3.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pytest>=2.6.0
pytest-twisted
pytest-cov
testfixtures
jmespath
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ mock
mitmproxy==0.10.1
netlib==0.10.1
pytest-twisted
pytest-cov
jmespath
testfixtures
14 changes: 13 additions & 1 deletion tests/test_command_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@ class VersionTest(ProcessTest, unittest.TestCase):
def test_output(self):
encoding = getattr(sys.stdout, 'encoding') or 'utf-8'
_, out, _ = yield self.execute([])
self.assertEqual(out.strip().decode(encoding), "Scrapy %s" % scrapy.__version__)
self.assertEqual(
out.strip().decode(encoding),
"Scrapy %s" % scrapy.__version__,
)

@defer.inlineCallbacks
def test_verbose_output(self):
encoding = getattr(sys.stdout, 'encoding') or 'utf-8'
_, out, _ = yield self.execute(['-v'])
headers = [l.partition(":")[0].strip()
for l in out.strip().decode(encoding).splitlines()]
self.assertEqual(headers, ['Scrapy', 'lxml', 'libxml2', 'Twisted',
'Python', 'pyOpenSSL', 'Platform'])
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ deps =
leveldb
-rtests/requirements.txt
commands =
py.test {posargs:scrapy tests}
py.test --cov=scrapy --cov-report= {posargs:scrapy tests}

[testenv:precise]
basepython = python2.7
Expand All @@ -34,7 +34,7 @@ basepython = python2.7
commands =
pip install -U https://github.com/scrapy/w3lib/archive/master.zip#egg=w3lib
pip install -U https://github.com/scrapy/queuelib/archive/master.zip#egg=queuelib
py.test {posargs:scrapy tests}
py.test --cov=scrapy --cov-report= {posargs:scrapy tests}

[testenv:py33]
basepython = python3.3
Expand Down

1 comment on commit 9adb5c3

@stav
Copy link
Contributor

@stav stav commented on 9adb5c3 Aug 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5000-th commit, nice.

Please sign in to comment.