From ad70a7db326e34f2e49a8676fe5e4893cd09763d Mon Sep 17 00:00:00 2001 From: Eugenio Lacuesta Date: Thu, 21 May 2020 13:32:24 -0300 Subject: [PATCH] Tox env with no dependencies --- .github/workflows/main.yml | 34 +++++++++++++++++++++++++++------- tests/requirements.txt | 5 ----- tests/test_utils.py | 25 ------------------------- tox.ini | 29 ++++++++++++++++++++++++++--- 4 files changed, 53 insertions(+), 40 deletions(-) delete mode 100644 tests/requirements.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e979653..7f9321a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: [push] jobs: checks: - name: Lint, typing, coverage + name: Flake8, typing, black runs-on: ubuntu-latest steps: @@ -27,12 +27,6 @@ jobs: - name: Black run: tox -e black - - name: Generate coverage report - run: tox -e py - - - name: Upload coverage report - run: bash <(curl -s https://codecov.io/bash) - tests-ubuntu: name: "Test: py${{ matrix.python-version }}, Ubuntu" @@ -55,6 +49,32 @@ jobs: - name: Run tests run: tox -e py + - name: Upload coverage report + run: bash <(curl -s https://codecov.io/bash) -cF tests + + + tests-no-deps: + name: "Test: python3.6, Ubuntu, no deps" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python 3.6 + uses: actions/setup-python@v1 + with: + python-version: 3.6 + + - name: Install tox + run: pip install tox + + - name: Run tests + run: tox -e no-deps + + - name: Upload coverage report + run: bash <(curl -s https://codecov.io/bash) -cF tests + + tests-other-os: name: "Test: py3.8, ${{ matrix.os }}" runs-on: "${{ matrix.os }}" diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index 671a10e..0000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -attrs -dataclasses; python_version == "3.6" -pytest-cov>=2.8 -pytest>=5.4 -scrapy>=2.0 diff --git a/tests/test_utils.py b/tests/test_utils.py index 8c4194a..c620610 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -6,10 +6,6 @@ from tests import AttrsItem, DataClassItem, ScrapyItem, ScrapySubclassedItem -def mocked_import(name, *args, **kwargs): - raise ImportError(name) - - class ItemLikeTestCase(unittest.TestCase): def test_false(self): self.assertFalse(is_item(int)) @@ -50,8 +46,6 @@ def test_false(self): self.assertFalse(is_attrs_instance(sum)) self.assertFalse(is_attrs_instance(1234)) self.assertFalse(is_attrs_instance(object())) - self.assertFalse(is_attrs_instance(ScrapyItem())) - self.assertFalse(is_attrs_instance(ScrapySubclassedItem())) self.assertFalse(is_attrs_instance("a string")) self.assertFalse(is_attrs_instance(b"some bytes")) self.assertFalse(is_attrs_instance({"a": "dict"})) @@ -60,11 +54,6 @@ def test_false(self): self.assertFalse(is_attrs_instance({"a", "set"})) self.assertFalse(is_attrs_instance(AttrsItem)) - @unittest.skipIf(not AttrsItem, "attrs module is not available") - @mock.patch("builtins.__import__", mocked_import) - def test_module_not_available(self): - self.assertFalse(is_attrs_instance(AttrsItem(name="asdf", value=1234))) - @unittest.skipIf(not AttrsItem, "attrs module is not available") def test_true(self): self.assertTrue(is_attrs_instance(AttrsItem())) @@ -77,9 +66,6 @@ def test_false(self): self.assertFalse(is_dataclass_instance(sum)) self.assertFalse(is_dataclass_instance(1234)) self.assertFalse(is_dataclass_instance(object())) - self.assertFalse(is_dataclass_instance(ScrapyItem())) - self.assertFalse(is_dataclass_instance(AttrsItem())) - self.assertFalse(is_dataclass_instance(ScrapySubclassedItem())) self.assertFalse(is_dataclass_instance("a string")) self.assertFalse(is_dataclass_instance(b"some bytes")) self.assertFalse(is_dataclass_instance({"a": "dict"})) @@ -88,11 +74,6 @@ def test_false(self): self.assertFalse(is_dataclass_instance({"a", "set"})) self.assertFalse(is_dataclass_instance(DataClassItem)) - @unittest.skipIf(not DataClassItem, "dataclasses module is not available") - @mock.patch("builtins.__import__", mocked_import) - def test_module_not_available(self): - self.assertFalse(is_dataclass_instance(DataClassItem(name="asdf", value=1234))) - @unittest.skipIf(not DataClassItem, "dataclasses module is not available") def test_true(self): self.assertTrue(is_dataclass_instance(DataClassItem())) @@ -105,7 +86,6 @@ def test_false(self): self.assertFalse(is_scrapy_item(sum)) self.assertFalse(is_scrapy_item(1234)) self.assertFalse(is_scrapy_item(object())) - self.assertFalse(is_scrapy_item(AttrsItem())) self.assertFalse(is_scrapy_item("a string")) self.assertFalse(is_scrapy_item(b"some bytes")) self.assertFalse(is_scrapy_item({"a": "dict"})) @@ -114,11 +94,6 @@ def test_false(self): self.assertFalse(is_scrapy_item({"a", "set"})) self.assertFalse(is_scrapy_item(ScrapySubclassedItem)) - @unittest.skipIf(not ScrapySubclassedItem, "scrapy module is not available") - @mock.patch("builtins.__import__", mocked_import) - def test_module_not_available(self): - self.assertFalse(is_scrapy_item(ScrapySubclassedItem(name="asdf", value=1234))) - @unittest.skipIf(not ScrapySubclassedItem, "scrapy module is not available") def test_true(self): self.assertTrue(is_scrapy_item(ScrapyItem())) diff --git a/tox.ini b/tox.ini index 62f80b4..119127e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,23 +1,46 @@ [tox] -envlist = py35,py36,py37,py38,flake8,typing,black +envlist = py35,py36,py37,py38,no-deps,flake8,typing,black [testenv] deps = - -rtests/requirements.txt + pytest>=5.4 + pytest-cov>=2.8 commands = - pytest --verbose --cov=itemadapter --cov-report=term-missing --cov-report=html --cov-report=xml {posargs: itemadapter tests} + pytest --verbose --cov=itemadapter --cov-report=term-missing --cov-report=html --cov-report=xml --cov-append {posargs: itemadapter tests} [testenv:py35] basepython = python3.5 +deps = + {[testenv]deps} + attrs + scrapy>=2.0 [testenv:py36] basepython = python3.6 +deps = + {[testenv]deps} + attrs + dataclasses + scrapy>=2.0 [testenv:py37] basepython = python3.7 +deps = + {[testenv]deps} + attrs + scrapy>=2.0 [testenv:py38] basepython = python3.8 +deps = + {[testenv]deps} + attrs + scrapy>=2.0 + +[testenv:no-deps] +deps = + {[testenv]deps} +basepython = python3.6 [testenv:flake8] basepython = python3.8