Skip to content

Commit

Permalink
Fix some PyFlakes issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdickinson committed Jan 12, 2014
1 parent 4e0bdef commit 272f21d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 61 deletions.
112 changes: 55 additions & 57 deletions traits/tests/test_abc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
""" Test the ABC functionality.
"""
import abc
import warnings

from traits.testing.unittest_tools import unittest
import warnings

from ..api import HasTraits
from ..api import ABCHasTraits, ABCMetaHasTraits, HasTraits, Int, Float


class TestNew(unittest.TestCase):
Expand All @@ -22,77 +23,74 @@ def test_new(self):
# Should not raise DeprecationWarning.
HasTraits(x=10)

try:
import abc

from ..api import ABCHasTraits, ABCMetaHasTraits, HasTraits, Int, Float
class AbstractFoo(ABCHasTraits):
x = Int(10)
y = Float(20.0)

@abc.abstractmethod
def foo(self):
raise NotImplementedError()

@abc.abstractproperty
def bar(self):
raise NotImplementedError()

class AbstractFoo(ABCHasTraits):
x = Int(10)
y = Float(20.0)

@abc.abstractmethod
def foo(self):
raise NotImplementedError()
class ConcreteFoo(AbstractFoo):
def foo(self):
return 'foo'

@abc.abstractproperty
def bar(self):
raise NotImplementedError()
@property
def bar(self):
return 'bar'

class ConcreteFoo(AbstractFoo):
def foo(self):
return 'foo'

@property
def bar(self):
return 'bar'
class FooLike(HasTraits):
x = Int(10)
y = Float(20.0)

class FooLike(HasTraits):
x = Int(10)
y = Float(20.0)
def foo(self):
return 'foo'

def foo(self):
return 'foo'
@property
def bar(self):
return 'bar'

@property
def bar(self):
return 'bar'

AbstractFoo.register(FooLike)
AbstractFoo.register(FooLike)

class AbstractBar(object):
__metaclass__ = abc.ABCMeta

@abc.abstractmethod
def bar(self):
raise NotImplementedError()
class AbstractBar(object):
__metaclass__ = abc.ABCMeta

class TestABC(unittest.TestCase):
def test_basic_abc(self):
self.assertRaises(TypeError, AbstractFoo)
concrete = ConcreteFoo()
self.assertEquals(concrete.foo(), 'foo')
self.assertEquals(concrete.bar, 'bar')
self.assertEquals(concrete.x, 10)
self.assertEquals(concrete.y, 20.0)
self.assertTrue(isinstance(concrete, AbstractFoo))
@abc.abstractmethod
def bar(self):
raise NotImplementedError()

def test_registered(self):
foolike = FooLike()
self.assertTrue(isinstance(foolike, AbstractFoo))

def test_post_hoc_mixing(self):
class TraitedBar(HasTraits, AbstractBar):
__metaclass__ = ABCMetaHasTraits
x = Int(10)
class TestABC(unittest.TestCase):
def test_basic_abc(self):
self.assertRaises(TypeError, AbstractFoo)
concrete = ConcreteFoo()
self.assertEquals(concrete.foo(), 'foo')
self.assertEquals(concrete.bar, 'bar')
self.assertEquals(concrete.x, 10)
self.assertEquals(concrete.y, 20.0)
self.assertTrue(isinstance(concrete, AbstractFoo))

def bar(self):
return 'bar'
def test_registered(self):
foolike = FooLike()
self.assertTrue(isinstance(foolike, AbstractFoo))

traited = TraitedBar()
self.assertTrue(isinstance(traited, AbstractBar))
self.assertEquals(traited.x, 10)
def test_post_hoc_mixing(self):
class TraitedBar(HasTraits, AbstractBar):
__metaclass__ = ABCMetaHasTraits
x = Int(10)

def bar(self):
return 'bar'

except ImportError:
pass
traited = TraitedBar()
self.assertTrue(isinstance(traited, AbstractBar))
self.assertEquals(traited.x, 10)
2 changes: 0 additions & 2 deletions traits/tests/test_extended_trait_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

from traits.testing.unittest_tools import unittest

from nose import SkipTest

from ..api import (Any, Dict, HasTraits, Instance, Int, List, Property,
TraitDictEvent, TraitError, TraitListEvent, Undefined,
cached_property, on_trait_change, pop_exception_handler,
Expand Down
2 changes: 0 additions & 2 deletions traits/tests/test_int_range_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

from __future__ import absolute_import

import sys

from traits.testing.unittest_tools import unittest

from ..api import HasTraits, Int, Range, Long, TraitError
Expand Down

0 comments on commit 272f21d

Please sign in to comment.