Skip to content

Commit

Permalink
Restore PEP8 cleanliness.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Jan 10, 2014
1 parent 92a3877 commit dbf94b3
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 41 deletions.
1 change: 1 addition & 0 deletions traits/tests/test_cythonized_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def has_no_compiler():
except:
return True


def cython_version():
if no_cython:
return None
Expand Down
4 changes: 2 additions & 2 deletions traits/tests/test_dynamic_notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_dynamic_notifiers_methods_failing(self):
obj = DynamicNotifiers()
obj.fail = 1

_py2to3.assertCountEqual(self, [0,1,2,3,4], obj.exceptions_from)
_py2to3.assertCountEqual(self, [0, 1, 2, 3, 4], obj.exceptions_from)
self.assertEqual([(obj, 'fail', 0, 1)]*5, self.exceptions)

def test_dynamic_notifiers_functions(self):
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_dynamic_notifiers_functions_failing(self):

obj.fail = 1

_py2to3.assertCountEqual(self, [0,1,2,3,4], obj.exceptions_from)
_py2to3.assertCountEqual(self, [0, 1, 2, 3, 4], obj.exceptions_from)
# 10 failures: 5 are from the internal dynamic listeners, see
# test_dynamic_notifiers_methods_failing
self.assertEqual([(obj, 'fail', 0, 1)] * 10, self.exceptions)
Expand Down
4 changes: 2 additions & 2 deletions traits/tests/test_extended_notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_extended_notifiers_methods_failing(self):
obj = ExtendedNotifiers()
obj.fail = 1

_py2to3.assertCountEqual(self, [0,1,2,3,4], obj.exceptions_from)
_py2to3.assertCountEqual(self, [0, 1, 2, 3, 4], obj.exceptions_from)
self.assertEqual([(obj, 'fail', 0, 1)]*5, self.exceptions)

def test_extended_notifiers_functions(self):
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_extended_notifiers_functions_failing(self):

obj.fail = 1

_py2to3.assertCountEqual(self, [0,1,2,3,4], obj.exceptions_from)
_py2to3.assertCountEqual(self, [0, 1, 2, 3, 4], obj.exceptions_from)
# 10 failures: 5 are from the internal extended listeners, see
# test_extended_notifiers_methods_failing
self.assertEqual([(obj, 'fail', 0, 1)] * 10, self.exceptions)
Expand Down
5 changes: 3 additions & 2 deletions traits/tests/test_interfaces_with_implements.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
Therefore, this test will fail due to the use of "adapts".
""")

#-------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Test 'Interface' definitions:
#-------------------------------------------------------------------------------
#------------------------------------------------------------------------------

class IFoo(Interface):

Expand Down
12 changes: 5 additions & 7 deletions traits/tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,12 @@ def test_coercion(self):
pass
else:
if sys.version_info[0] < 3:
f.ints = array([1,2,3])
self.failUnlessEqual( f.ints, [1,2,3] )
f.ints = array([1, 2, 3])
self.failUnlessEqual(f.ints, [1, 2, 3])
else:
# These would fail due to np.int_ being an invalid vallue
# for the Int-trait.
# for the Int-trait.
pass

f.strs = array( ("abc", "def", "ghi") )
self.failUnlessEqual( f.strs, ["abc", "def", "ghi"] )

### EOF
f.strs = array(("abc", "def", "ghi"))
self.failUnlessEqual(f.strs, ["abc", "def", "ghi"])
56 changes: 29 additions & 27 deletions traits/tests/test_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ class IntTest(AnyTraitTest):
obj = IntTrait()

_default_value = 99
_good_values = [10, -10]
_bad_values = ['ten', u'ten', [10], {'ten': 10},(10,), None, 1j,
10.1, -10.1, '10L', '-10L', '10.1', '-10.1', u'10L',
u'-10L', u'10.1', u'-10.1', '10', '-10', u'10', u'-10']
_good_values = [10, -10]
_bad_values = ['ten', u'ten', [10], {'ten': 10}, (10,), None, 1j,
10.1, -10.1, '10L', '-10L', '10.1', '-10.1', u'10L',
u'-10L', u'10.1', u'-10.1', '10', '-10', u'10', u'-10']

try:
import numpy as np
Expand All @@ -162,20 +162,20 @@ class IntTest(AnyTraitTest):
else:
if sys.version_info[0] < 3:
_good_values.extend([
np.int64(10),np.int64(-10),
np.int32(10),np.int32(-10),
np.int_(10),np.int_(-10)
np.int64(10), np.int64(-10),
np.int32(10), np.int32(-10),
np.int_(10), np.int_(-10)
])
_bad_values.extend([
])
else:
#TODO: status of numpy-ints is unclear in python 3!
pass

if sys.version_info[0] < 3:
# 2to3 will remove the L suffix and therfore make them actually good ones!
_bad_values.extend([-10L,10L])
# 2to3 will remove the L suffix and therefore make them actually good
# ones!
_bad_values.extend([-10L, 10L])

def coerce(self, value):
try:
Expand All @@ -200,11 +200,12 @@ class CoercibleLongTest(AnyTraitTest):
obj = CoercibleLongTrait()

_default_value = 99L
_good_values = [10, -10, 10L, -10L, 10.1, -10.1, '10', '-10', u'10', u'-10']
_good_values = [
10, -10, 10L, -10L, 10.1, -10.1, '10', '-10', u'10', u'-10']
if sys.version_info[0] < 3:
_good_values.extend(['10L','-10L',u'10L',u'-10L'])
_bad_values = ['10.1', '-10.1', u'10.1', u'-10.1', 'ten', u'ten', [10],
[10l], {'ten': 10},(10,),(10L,), None, 1j]
_good_values.extend(['10L', '-10L', u'10L', u'-10L'])
_bad_values = ['10.1', '-10.1', u'10.1', u'-10.1', 'ten', u'ten', [10],
[10l], {'ten': 10}, (10,), (10L,), None, 1j]

def coerce(self, value):
try:
Expand Down Expand Up @@ -259,15 +260,15 @@ class FloatTest(AnyTraitTest):
obj = FloatTrait()

_default_value = 99.0
_good_values = [10, -10, 10.1, -10.1]
_bad_values = ['ten', u'ten', [10], {'ten': 10},(10,), None,
1j, '10', '-10', '10L', '-10L', '10.1', '-10.1', u'10',
u'-10', u'10L', u'-10L', u'10.1', u'-10.1']
_good_values = [10, -10, 10.1, -10.1]
_bad_values = ['ten', u'ten', [10], {'ten': 10}, (10,), None,
1j, '10', '-10', '10L', '-10L', '10.1', '-10.1', u'10',
u'-10', u'10L', u'-10L', u'10.1', u'-10.1']

if sys.version_info[0] < 3:
# 2to3 will remove the L suffix and therfore make them actually good ones!
_bad_values.extend([-10L,10L])

# 2to3 will remove the L suffix and therfore make them actually good
# ones!
_bad_values.extend([-10L, 10L])

def coerce(self, value):
try:
Expand Down Expand Up @@ -814,10 +815,10 @@ def test_enum_exceptions(self):

class list_value(HasTraits):
# Trait definitions:
list1 = Trait([ 2 ], TraitList(Trait([ 1, 2, 3, 4 ]),
maxlen = 4))
list2 = Trait([ 2 ], TraitList(Trait([ 1, 2, 3, 4 ]),
minlen = 1, maxlen = 4))
list1 = Trait([2], TraitList(Trait([1, 2, 3, 4]),
maxlen=4))
list2 = Trait([2], TraitList(Trait([1, 2, 3, 4]),
minlen=1, maxlen=4))
alist = List()


Expand Down Expand Up @@ -916,7 +917,8 @@ def test_trait_list_event(self):
# If no values changed, no new TraitListEvent will be generated.
self.assertIs(self.last_event, old_event)
self.obj.alist[0:4:2] = [10, 11]
self.assertLastTraitListEventEqual(slice(0, 4, 2), [[8, 4]], [[10, 11]])
self.assertLastTraitListEventEqual(
slice(0, 4, 2), [[8, 4]], [[10, 11]])
del self.obj.alist[1:4:2]
self.assertLastTraitListEventEqual(slice(1, 4, 2), [[9, 5]], [])
self.obj.alist = [1, 2, 3, 4]
Expand Down
1 change: 0 additions & 1 deletion traits/tests/test_ui_notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def on_foo_notifications(self, obj, name, old, new):

#### Tests ################################################################


@unittest.skipIf(
not QT_FOUND, "Qt event loop not found, UI dispatch not possible.")
def test_notification_from_main_thread(self):
Expand Down

0 comments on commit dbf94b3

Please sign in to comment.