Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tox env with no dependencies (python tag) #23

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

jobs:
checks:
name: Lint, typing, coverage
name: Flake8, typing, black
runs-on: ubuntu-latest

steps:
Expand All @@ -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"
Expand All @@ -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 python


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 python


tests-other-os:
name: "Test: py3.8, ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
Expand Down
5 changes: 0 additions & 5 deletions tests/requirements.txt

This file was deleted.

25 changes: 0 additions & 25 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"}))
Expand All @@ -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()))
Expand All @@ -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"}))
Expand All @@ -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()))
Expand All @@ -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"}))
Expand All @@ -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()))
Expand Down
29 changes: 26 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down