From deb922d57dbd2315e9eca9531469ba9b5f139178 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Tue, 16 Jul 2024 03:34:20 -0400 Subject: [PATCH] test: Move tests directory for easier coveralls configuration --- .github/workflows/tests.yml | 2 +- .gitignore | 2 +- docs/contributing.rst | 19 +++++++----------- setup.cfg | 4 ---- {scrapyd/tests => tests}/__init__.py | 0 {scrapyd/tests => tests}/conftest.py | 0 {scrapyd/tests => tests}/logstdout.egg | Bin {scrapyd/tests => tests}/mockserver.py | 2 +- {scrapyd/tests => tests}/mybot.egg | Bin {scrapyd/tests => tests}/mybot2.egg | Bin {scrapyd/tests => tests}/mybot3.egg | Bin {scrapyd/tests => tests}/mybotunicode.egg | Bin {scrapyd/tests => tests}/quotesbot.egg | Bin .../tests => tests}/quotesbot_asyncio.egg | Bin {scrapyd/tests => tests}/start_mock_app.py | 0 .../test_dont_load_settings.py | 0 {scrapyd/tests => tests}/test_eggstorage.py | 2 +- {scrapyd/tests => tests}/test_endpoints.py | 2 +- {scrapyd/tests => tests}/test_environ.py | 0 {scrapyd/tests => tests}/test_jobstorage.py | 0 {scrapyd/tests => tests}/test_poller.py | 0 {scrapyd/tests => tests}/test_scheduler.py | 0 {scrapyd/tests => tests}/test_scripts.py | 2 +- {scrapyd/tests => tests}/test_spiderqueue.py | 0 {scrapyd/tests => tests}/test_sqlite.py | 0 {scrapyd/tests => tests}/test_utils.py | 2 +- {scrapyd/tests => tests}/test_webservice.py | 0 {scrapyd/tests => tests}/test_website.py | 0 28 files changed, 14 insertions(+), 23 deletions(-) rename {scrapyd/tests => tests}/__init__.py (100%) rename {scrapyd/tests => tests}/conftest.py (100%) rename {scrapyd/tests => tests}/logstdout.egg (100%) rename {scrapyd/tests => tests}/mockserver.py (97%) rename {scrapyd/tests => tests}/mybot.egg (100%) rename {scrapyd/tests => tests}/mybot2.egg (100%) rename {scrapyd/tests => tests}/mybot3.egg (100%) rename {scrapyd/tests => tests}/mybotunicode.egg (100%) rename {scrapyd/tests => tests}/quotesbot.egg (100%) rename {scrapyd/tests => tests}/quotesbot_asyncio.egg (100%) rename {scrapyd/tests => tests}/start_mock_app.py (100%) rename {scrapyd/tests => tests}/test_dont_load_settings.py (100%) rename {scrapyd/tests => tests}/test_eggstorage.py (97%) rename {scrapyd/tests => tests}/test_endpoints.py (98%) rename {scrapyd/tests => tests}/test_environ.py (100%) rename {scrapyd/tests => tests}/test_jobstorage.py (100%) rename {scrapyd/tests => tests}/test_poller.py (100%) rename {scrapyd/tests => tests}/test_scheduler.py (100%) rename {scrapyd/tests => tests}/test_scripts.py (89%) rename {scrapyd/tests => tests}/test_spiderqueue.py (100%) rename {scrapyd/tests => tests}/test_sqlite.py (100%) rename {scrapyd/tests => tests}/test_utils.py (98%) rename {scrapyd/tests => tests}/test_webservice.py (100%) rename {scrapyd/tests => tests}/test_website.py (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d6b72de5..ddda0810 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.gitignore b/.gitignore index 7bd1d1ab..a54ee8d1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ venv /_trial_temp /dbs /htmlcov -/scrapyd.tests.test_* +/tests.test_* /scrapyd.conf /twistd.pid /eggs diff --git a/docs/contributing.rst b/docs/contributing.rst index 2fe3427d..12ef2192 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -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 `__ 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 `__ 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 `__. 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 @@ -38,7 +38,7 @@ 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 `__ directory. Their module name typically resembles the full path of the module they're testing. For example, the scheduler code is in:: @@ -46,7 +46,7 @@ testing. For example, the scheduler code is in:: And their unit-tests are in:: - scrapyd/tests/test_scheduler.py + tests/test_scheduler.py Installing locally ------------------ @@ -54,8 +54,3 @@ 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 diff --git a/setup.cfg b/setup.cfg index 2281f70a..61cf6086 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,6 @@ [bdist_wheel] universal = 1 -[coverage:run] -include = scrapyd/* -omit = scrapyd/tests* - [flake8] max-line-length = 119 diff --git a/scrapyd/tests/__init__.py b/tests/__init__.py similarity index 100% rename from scrapyd/tests/__init__.py rename to tests/__init__.py diff --git a/scrapyd/tests/conftest.py b/tests/conftest.py similarity index 100% rename from scrapyd/tests/conftest.py rename to tests/conftest.py diff --git a/scrapyd/tests/logstdout.egg b/tests/logstdout.egg similarity index 100% rename from scrapyd/tests/logstdout.egg rename to tests/logstdout.egg diff --git a/scrapyd/tests/mockserver.py b/tests/mockserver.py similarity index 97% rename from scrapyd/tests/mockserver.py rename to tests/mockserver.py index 49e2f826..120b9870 100644 --- a/scrapyd/tests/mockserver.py +++ b/tests/mockserver.py @@ -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: diff --git a/scrapyd/tests/mybot.egg b/tests/mybot.egg similarity index 100% rename from scrapyd/tests/mybot.egg rename to tests/mybot.egg diff --git a/scrapyd/tests/mybot2.egg b/tests/mybot2.egg similarity index 100% rename from scrapyd/tests/mybot2.egg rename to tests/mybot2.egg diff --git a/scrapyd/tests/mybot3.egg b/tests/mybot3.egg similarity index 100% rename from scrapyd/tests/mybot3.egg rename to tests/mybot3.egg diff --git a/scrapyd/tests/mybotunicode.egg b/tests/mybotunicode.egg similarity index 100% rename from scrapyd/tests/mybotunicode.egg rename to tests/mybotunicode.egg diff --git a/scrapyd/tests/quotesbot.egg b/tests/quotesbot.egg similarity index 100% rename from scrapyd/tests/quotesbot.egg rename to tests/quotesbot.egg diff --git a/scrapyd/tests/quotesbot_asyncio.egg b/tests/quotesbot_asyncio.egg similarity index 100% rename from scrapyd/tests/quotesbot_asyncio.egg rename to tests/quotesbot_asyncio.egg diff --git a/scrapyd/tests/start_mock_app.py b/tests/start_mock_app.py similarity index 100% rename from scrapyd/tests/start_mock_app.py rename to tests/start_mock_app.py diff --git a/scrapyd/tests/test_dont_load_settings.py b/tests/test_dont_load_settings.py similarity index 100% rename from scrapyd/tests/test_dont_load_settings.py rename to tests/test_dont_load_settings.py diff --git a/scrapyd/tests/test_eggstorage.py b/tests/test_eggstorage.py similarity index 97% rename from scrapyd/tests/test_eggstorage.py rename to tests/test_eggstorage.py index 4b8ba3b8..6b755699 100644 --- a/scrapyd/tests/test_eggstorage.py +++ b/tests/test_eggstorage.py @@ -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) diff --git a/scrapyd/tests/test_endpoints.py b/tests/test_endpoints.py similarity index 98% rename from scrapyd/tests/test_endpoints.py rename to tests/test_endpoints.py index f0564501..3de31cf6 100644 --- a/scrapyd/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -5,7 +5,7 @@ import requests from requests.models import Response -from scrapyd.tests.mockserver import MockScrapyDServer +from tests.mockserver import MockScrapyDServer @pytest.fixture diff --git a/scrapyd/tests/test_environ.py b/tests/test_environ.py similarity index 100% rename from scrapyd/tests/test_environ.py rename to tests/test_environ.py diff --git a/scrapyd/tests/test_jobstorage.py b/tests/test_jobstorage.py similarity index 100% rename from scrapyd/tests/test_jobstorage.py rename to tests/test_jobstorage.py diff --git a/scrapyd/tests/test_poller.py b/tests/test_poller.py similarity index 100% rename from scrapyd/tests/test_poller.py rename to tests/test_poller.py diff --git a/scrapyd/tests/test_scheduler.py b/tests/test_scheduler.py similarity index 100% rename from scrapyd/tests/test_scheduler.py rename to tests/test_scheduler.py diff --git a/scrapyd/tests/test_scripts.py b/tests/test_scripts.py similarity index 89% rename from scrapyd/tests/test_scripts.py rename to tests/test_scripts.py index 347bb073..3d717ab4 100644 --- a/scrapyd/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -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): diff --git a/scrapyd/tests/test_spiderqueue.py b/tests/test_spiderqueue.py similarity index 100% rename from scrapyd/tests/test_spiderqueue.py rename to tests/test_spiderqueue.py diff --git a/scrapyd/tests/test_sqlite.py b/tests/test_sqlite.py similarity index 100% rename from scrapyd/tests/test_sqlite.py rename to tests/test_sqlite.py diff --git a/scrapyd/tests/test_utils.py b/tests/test_utils.py similarity index 98% rename from scrapyd/tests/test_utils.py rename to tests/test_utils.py index 41a80267..69767c6f 100644 --- a/scrapyd/tests/test_utils.py +++ b/tests/test_utils.py @@ -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): diff --git a/scrapyd/tests/test_webservice.py b/tests/test_webservice.py similarity index 100% rename from scrapyd/tests/test_webservice.py rename to tests/test_webservice.py diff --git a/scrapyd/tests/test_website.py b/tests/test_website.py similarity index 100% rename from scrapyd/tests/test_website.py rename to tests/test_website.py