Skip to content

Commit

Permalink
test: Move tests directory for easier coveralls configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jul 16, 2024
1 parent 9e6d6a3 commit deb922d
Show file tree
Hide file tree
Showing 28 changed files with 14 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
cache: pip
cache-dependency-path: setup.py
- run: pip install -e .[test]
- run: pytest scrapyd --cov=. --cov-report=xml
- run: pytest tests --cov scrapyd
- name: Run integration tests
run: |
printf "[scrapyd]\nusername = hello12345\npassword = 67890world\n" > scrapyd.conf
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ venv
/_trial_temp
/dbs
/htmlcov
/scrapyd.tests.test_*
/tests.test_*
/scrapyd.conf
/twistd.pid
/eggs
Expand Down
19 changes: 7 additions & 12 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ Contributing

.. important::

Read through the `Scrapy Contribution Docs`_ for tips relating to writing patches, reporting bugs, and project coding style
Read through the `Scrapy Contribution Docs <http://scrapy.readthedocs.org/en/latest/contributing.html>`__ for tips relating to writing patches, reporting bugs, and project coding style

These docs describe how to setup and contribute to Scrapyd.

Reporting issues & bugs
-----------------------

Issues should be reported to the Scrapyd project `issue tracker`_ on GitHub
Issues should be reported to the Scrapyd project `issue tracker <https://github.com/scrapy/scrapyd/issues>`__ on GitHub.

Tests
-----

Tests are implemented using the `Twisted unit-testing framework`_. Scrapyd uses ``trial`` as the test running application.
Tests are implemented using the `Twisted unit-testing framework <http://twistedmatrix.com/documents/current/core/development/policy/test-standard.html>`__. Scrapyd uses ``trial`` as the test running application.

Running tests
-------------

To run all tests go to the root directory of the Scrapyd source code and run:

``trial scrapyd``
``trial tests``

To run a specific test (say ``tests/test_poller.py``) use:

``trial scrapyd.tests.test_poller``
``trial tests.test_poller``


Writing tests
Expand All @@ -38,24 +38,19 @@ All functionality (including new features and bug fixes) should include a test
case to check that it works as expected, so please include tests for your
patches if you want them to get accepted sooner.

Scrapyd uses unit-tests, which are located in the `scrapyd/tests`_ directory.
Scrapyd uses unit-tests, which are located in the `tests <https://github.com/scrapy/scrapyd/tree/master/tests>`__ directory.
Their module name typically resembles the full path of the module they're
testing. For example, the scheduler code is in::

scrapyd.scheduler

And their unit-tests are in::

scrapyd/tests/test_scheduler.py
tests/test_scheduler.py

Installing locally
------------------

To install a locally edited version of Scrapyd onto the system to use and test, inside the project root run:

``pip install -e .``

.. _Twisted unit-testing framework: http://twistedmatrix.com/documents/current/core/development/policy/test-standard.html
.. _scrapyd/tests: https://github.com/scrapy/scrapyd/tree/master/scrapyd/tests
.. _issue tracker: https://github.com/scrapy/scrapyd/issues
.. _Scrapy Contribution Docs: http://scrapy.readthedocs.org/en/latest/contributing.html
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[bdist_wheel]
universal = 1

[coverage:run]
include = scrapyd/*
omit = scrapyd/tests*

[flake8]
max-line-length = 119

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scrapyd/tests/mockserver.py → tests/mockserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __enter__(self, authentication=None):
"""
command = [
sys.executable, '-m',
"scrapyd.tests.start_mock_app",
"tests.start_mock_app",
get_ephemeral_port()
]
if self.authentication is not None:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def delete(self, project, version=None):
class TestConfigureEggStorage(unittest.TestCase):
def test_egg_config_application(self):
config = Config()
eggstore = 'scrapyd.tests.test_eggstorage.SomeFakeEggStorage'
eggstore = 'tests.test_eggstorage.SomeFakeEggStorage'
config.cp.set('scrapyd', 'eggstorage', eggstore)
app = application(config)
app_eggstorage = app.getComponent(IEggStorage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import requests
from requests.models import Response

from scrapyd.tests.mockserver import MockScrapyDServer
from tests.mockserver import MockScrapyDServer


@pytest.fixture
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scrapyd/tests/test_scripts.py → tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from scrapyd.__main__ import main

__version__ = pkgutil.get_data(__package__, '../VERSION').decode('ascii').strip()
__version__ = pkgutil.get_data(__package__, '../scrapyd/VERSION').decode('ascii').strip()


def test_print_version(capsys, monkeypatch):
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scrapyd/tests/test_utils.py → tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def setUp(self):

def add_test_version(self, file, project, version):
eggstorage = self.app.getComponent(IEggStorage)
eggfile = BytesIO(get_data("scrapyd.tests", file))
eggfile = BytesIO(get_data("tests", file))
eggstorage.put(eggfile, project, version)

def test_get_spider_list_log_stdout(self):
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit deb922d

Please sign in to comment.