Skip to content

remove suppor for Python <= 3.3 #119

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ coverage
flake8
pytest
pytest-cov
six>=1.4.0
PyYAML
mock; python_version < '3.3'
72 changes: 26 additions & 46 deletions test/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import os
import json
from sys import modules
import pytest
import six
from unittest import mock

try:
from unittest import mock
except ImportError:
import mock
import pytest

from ddt import ddt, data, file_data, idata, TestNameFormat

Expand All @@ -19,7 +15,7 @@ class CustomClass:


@ddt
class Dummy(object):
class Dummy:
"""
Dummy class to test the data decorator on
"""
Expand All @@ -30,7 +26,7 @@ def test_something(self, value):


@ddt(testNameFormat=TestNameFormat.DEFAULT)
class DummyTestNameFormatDefault(object):
class DummyTestNameFormatDefault:
"""
Dummy class to test the ddt decorator that generates test names using the
default format (index and values).
Expand All @@ -42,7 +38,7 @@ def test_something(self, value):


@ddt(testNameFormat=TestNameFormat.INDEX_ONLY)
class DummyTestNameFormatIndexOnly(object):
class DummyTestNameFormatIndexOnly:
"""
Dummy class to test the ddt decorator that generates test names using only
the index.
Expand All @@ -66,7 +62,7 @@ def test_data_with_invalid_identifier(self, value):


@ddt
class FileDataDummy(object):
class FileDataDummy:
"""
Dummy class to test the file_data decorator on
"""
Expand All @@ -77,7 +73,7 @@ def test_something_again(self, value):


@ddt
class JSONFileDataMissingDummy(object):
class JSONFileDataMissingDummy:
"""
Dummy class to test the file_data decorator on when
JSON file is missing
Expand All @@ -89,7 +85,7 @@ def test_something_again(self, value):


@ddt
class YAMLFileDataMissingDummy(object):
class YAMLFileDataMissingDummy:
"""
Dummy class to test the file_data decorator on when
YAML file is missing
Expand Down Expand Up @@ -190,7 +186,7 @@ def test_idata_single_argument():
payload = [5, 12, 13]

@ddt
class Dummy(object):
class Dummy:
"""Dummy class to test that the ``idata(iterable)`` decorator works."""
@idata(payload)
def test_something(self, value):
Expand All @@ -213,7 +209,7 @@ def test_idata_automatic_zero_padding():
payload = range(15)

@ddt
class Dummy(object):
class Dummy:
"""Dummy class to test that the ``idata(iterable)`` decorator works."""
@idata(payload)
def test_something(self, value):
Expand All @@ -236,7 +232,7 @@ def test_idata_override_index_len():
payload = [4, 2, 1]

@ddt
class Dummy(object):
class Dummy:
@idata(payload, index_len=2)
def test_something(self, value):
return value
Expand All @@ -263,7 +259,7 @@ def consumable_iterator():
yield i

@ddt
class Dummy(object):
class Dummy:
@idata(consumable_iterator())
def test_something(self, value):
return value
Expand Down Expand Up @@ -374,7 +370,7 @@ def hello():
class Myint(int):
pass

class Mytest(object):
class Mytest:
pass

d1 = Myint(1)
Expand Down Expand Up @@ -409,7 +405,7 @@ def func_wo_doc():
class Myint(int):
pass

class Mytest(object):
class Mytest:
pass

d1 = Myint(1)
Expand Down Expand Up @@ -448,31 +444,15 @@ def test_ddt_data_unicode():
"""
Test that unicode strings are converted to function names correctly
"""
# We test unicode support separately for python 2 and 3

if six.PY2:

@ddt
class Mytest(object):
@data(u'ascii', u'non-ascii-\N{SNOWMAN}', {u'\N{SNOWMAN}': 'data'})
def test_hello(self, val):
pass

assert getattr(Mytest, 'test_hello_1_ascii') is not None
assert getattr(Mytest, 'test_hello_2_non_ascii__u2603') is not None
assert getattr(Mytest, 'test_hello_3') is not None

elif six.PY3:

@ddt
class Mytest(object):
@data('ascii', 'non-ascii-\N{SNOWMAN}', {'\N{SNOWMAN}': 'data'})
def test_hello(self, val):
pass
@ddt
class Mytest:
@data('ascii', 'non-ascii-\N{SNOWMAN}', {'\N{SNOWMAN}': 'data'})
def test_hello(self, val):
pass

assert getattr(Mytest, 'test_hello_1_ascii') is not None
assert getattr(Mytest, 'test_hello_2_non_ascii__') is not None
assert getattr(Mytest, 'test_hello_3') is not None
assert getattr(Mytest, 'test_hello_1_ascii') is not None
assert getattr(Mytest, 'test_hello_2_non_ascii__') is not None
assert getattr(Mytest, 'test_hello_3') is not None


def test_ddt_data_object():
Expand All @@ -481,7 +461,7 @@ def test_ddt_data_object():
"""

@ddt
class Mytest(object):
class Mytest:
@data(object())
def test_object(self, val):
pass
Expand Down Expand Up @@ -511,7 +491,7 @@ def test_load_yaml_without_yaml_support():
"""

@ddt
class NoYAMLInstalledTest(object):
class NoYAMLInstalledTest:

@file_data('data/test_data_dict.yaml')
def test_file_data_yaml_dict(self, value):
Expand Down Expand Up @@ -540,7 +520,7 @@ def str_to_type(class_name):

try:
@ddt
class YamlDefaultLoaderTest(object):
class YamlDefaultLoaderTest:
@file_data('data/test_functional_custom_tags.yaml')
def test_cls_is_instance(self, cls, expected):
assert isinstance(cls, str_to_type(expected))
Expand All @@ -549,7 +529,7 @@ def test_cls_is_instance(self, cls, expected):
raise AssertionError()

@ddt
class YamlUnsafeLoaderTest(object):
class YamlUnsafeLoaderTest:
@file_data('data/test_functional_custom_tags.yaml', UnsafeLoader)
def test_cls_is_instance(self, instance, expected):
assert isinstance(instance, str_to_type(expected))
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ deps =
coverage
aiounittest
flake8
six>=1.4.0
PyYAML
commands =
pytest --cov=ddt --cov-report html
Expand Down