From d92f8f36570373c21e1722682bdd69c2320bdfe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carles=20Barrob=C3=A9s?= Date: Mon, 25 Feb 2013 00:34:48 +0000 Subject: [PATCH] Adapt tests to run on Python3 --- .gitignore | 1 + test/test_example.py | 2 +- test/test_functional.py | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 54c93c6..dac2600 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +*.swp build/ dist/ ddt.egg-info/ diff --git a/test/test_example.py b/test/test_example.py index c89d1c0..23c747c 100644 --- a/test/test_example.py +++ b/test/test_example.py @@ -1,6 +1,6 @@ import unittest from ddt import ddt, data -from mycode import larger_than_two +from .mycode import larger_than_two class mylist(list): diff --git a/test/test_functional.py b/test/test_functional.py index b7b4ca2..26478d9 100644 --- a/test/test_functional.py +++ b/test/test_functional.py @@ -18,13 +18,13 @@ def test_data_decorator(): pass pre_size = len(hello.__dict__) - keys = hello.__dict__.keys() + keys = set(hello.__dict__.keys()) data_hello = data(1, 2)(hello) - dh_keys = data_hello.__dict__.keys() + dh_keys = set(data_hello.__dict__.keys()) post_size = len(data_hello.__dict__) assert_equal(post_size, pre_size + 1) - extra_attrs = set(dh_keys) - set(keys) + extra_attrs = dh_keys - keys assert_equal(len(extra_attrs), 1) extra_attr = extra_attrs.pop() assert_equal(getattr(data_hello, extra_attr), (1, 2)) @@ -36,7 +36,7 @@ is_test = lambda x: x.startswith('test_') def test_ddt(): """Test the ``ddt`` class decorator""" - tests = len(filter(is_test, Dummy.__dict__)) + tests = len(list(filter(is_test, Dummy.__dict__))) assert_equal(tests, 4)