Skip to content

Commit

Permalink
Remove unittest2 (#419)
Browse files Browse the repository at this point in the history
* Remove unittest2 framework

* Skip a couple of tests on Python 2.7

* Update changelog
  • Loading branch information
rmk135 committed Mar 6, 2021
1 parent 6b57ce9 commit d4ebb1b
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ uninstall:
test-py2: build
# Unit tests with coverage report
coverage erase
coverage run --rcfile=./.coveragerc -m unittest2 discover -s tests/unit/ -p test_*_py2_py3.py
coverage run --rcfile=./.coveragerc -m unittest discover -s tests/unit/ -p test_*_py2_py3.py
coverage report --rcfile=./.coveragerc
coverage html --rcfile=./.coveragerc

test: build
# Unit tests with coverage report
coverage erase
coverage run --rcfile=./.coveragerc -m unittest2 discover -s tests/unit/ -p test_*py3*.py
coverage run --rcfile=./.coveragerc -m unittest discover -s tests/unit/ -p test_*py3*.py
coverage report --rcfile=./.coveragerc
coverage html --rcfile=./.coveragerc

Expand Down
1 change: 1 addition & 0 deletions docs/main/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ follows `Semantic versioning`_
Thanks to `@GitterRemote <https://github.com/GitterRemote>`_ for reporting the issue.
- Add docs and example for ``Factory.add_attributes()`` method.
- Remove legacy css file.
- Remove ``unittest2`` test dependency.

4.29.0
------
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cython==0.29.21
tox
unittest2
coverage
flake8
pydocstyle
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/containers/test_declarative_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Dependency injector declarative container unit tests."""

import collections
import unittest2 as unittest
import unittest

from dependency_injector import (
containers,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/containers/test_dynamic_async_resources_py36.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector dynamic container unit tests for async resources."""

import unittest2 as unittest
import unittest

# Runtime import to get asyncutils module
import os
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/containers/test_dynamic_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector dynamic container unit tests."""

import unittest2 as unittest
import unittest

from dependency_injector import (
containers,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ext/test_flask_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector Flask extension unit tests."""

import unittest2 as unittest
import unittest
from flask import Flask, url_for
from flask.views import MethodView

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_base_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector base providers unit tests."""

import unittest2 as unittest
import unittest

from dependency_injector import (
containers,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_callables_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

import unittest2 as unittest
import unittest

from dependency_injector import (
providers,
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/providers/test_configuration_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import tempfile

import unittest2 as unittest
import unittest

from dependency_injector import containers, providers, errors
try:
Expand Down Expand Up @@ -106,6 +106,7 @@ def test_as_(self):

self.assertEqual(value, decimal.Decimal('123.123'))

@unittest.skipIf(sys.version_info[:2] == (2, 7), 'Python 2.7 does not support this assert')
def test_required(self):
provider = providers.Callable(
lambda value: value,
Expand Down Expand Up @@ -218,11 +219,13 @@ def test_providers_with_default_value_overriding(self):
def test_value_of_undefined_option(self):
self.assertIsNone(self.config.a())

@unittest.skipIf(sys.version_info[:2] == (2, 7), 'Python 2.7 does not support this assert')
def test_value_of_undefined_option_in_strict_mode(self):
self.config = providers.Configuration(strict=True)
with self.assertRaisesRegex(errors.Error, 'Undefined configuration option "config.a"'):
self.config.a()

@unittest.skipIf(sys.version_info[:2] == (2, 7), 'Python 2.7 does not support this assert')
def test_value_of_undefined_option_with_root_none_in_strict_mode(self):
self.config = providers.Configuration(strict=True)
self.config.override(None)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_container_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import copy

import unittest2 as unittest
import unittest

from dependency_injector import containers, providers, errors

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_coroutines_py35.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio

import unittest2 as unittest
import unittest

from dependency_injector import (
providers,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_dict_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

import unittest2 as unittest
import unittest

from dependency_injector import providers

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_factories_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

import unittest2 as unittest
import unittest

from dependency_injector import (
providers,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_injections_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector injections unit tests."""

import unittest2 as unittest
import unittest

from dependency_injector import providers

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_list_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

import unittest2 as unittest
import unittest

from dependency_injector import providers

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_provided_instance_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector provided instance provider unit tests."""

import unittest2 as unittest
import unittest

from dependency_injector import containers, providers

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_resource_py35.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio

import unittest2 as unittest
import unittest

from dependency_injector import containers, providers, resources, errors

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_selector_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import itertools
import sys

import unittest2 as unittest
import unittest

from dependency_injector import providers, errors

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_singletons_py2_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

import unittest2 as unittest
import unittest

from dependency_injector import (
providers,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/providers/test_utils_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector provider utils unit tests."""

import unittest2 as unittest
import unittest

from dependency_injector import (
providers,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_common_py2_py3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Dependency injector common unit tests."""

import unittest2 as unittest
import unittest

from dependency_injector import __version__

Expand Down
17 changes: 6 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ envlist=

[testenv]
deps=
unittest2
# TODO: Hotfix, remove when fixed https://github.com/aio-libs/aiohttp/issues/5107
typing_extensions
httpx
Expand All @@ -15,7 +14,7 @@ extras=
flask
aiohttp
commands=
unit2 discover -s tests/unit -p test_*_py3*.py
python -m unittest discover -s tests/unit -p test_*_py3*.py

[testenv:coveralls]
passenv = GITHUB_* COVERALLS_*
Expand All @@ -28,44 +27,40 @@ deps=
coveralls
commands=
coverage erase
coverage run --rcfile=./.coveragerc -m unittest2 discover -s tests/unit/ -p test_*_py3*.py
coverage run --rcfile=./.coveragerc -m unittest discover -s tests/unit/ -p test_*_py3*.py
coverage report --rcfile=./.coveragerc
coveralls

[testenv:2.7]
deps=
unittest2
extras=
yaml
flask
commands=
unit2 discover -s tests/unit -p test_*_py2_py3.py
python -m unittest discover -s tests/unit -p test_*_py2_py3.py

[testenv:3.4]
deps=
unittest2
extras=
flask
commands=
unit2 discover -s tests/unit -p test_*_py3.py
python -m unittest discover -s tests/unit -p test_*_py3.py

[testenv:3.5]
deps=
unittest2
extras=
yaml
flask
commands=
unit2 discover -s tests/unit -p test_*_py3.py
python -m unittest discover -s tests/unit -p test_*_py3.py

[testenv:pypy2]
deps=
unittest2
extras=
yaml
flask
commands=
unit2 discover -s tests/unit -p test_*_py2_py3.py
python -m unittest discover -s tests/unit -p test_*_py2_py3.py

[testenv:pylint]
deps=
Expand Down

0 comments on commit d4ebb1b

Please sign in to comment.