Skip to content

Commit

Permalink
Unbound methods are gone in Py3 so there is no easy way to support 'o…
Browse files Browse the repository at this point in the history
…verridden' function

for unbound methods in Py3 because they look like regular functions and doesn't store reference to a class.
That feature is not used in NLTK own codebase so I removed it from tests. This make 'nltk.internals' tests
("tox -- nltk.internals internals.doctest") pass for all platforms.
  • Loading branch information
kmike committed May 18, 2012
1 parent 466fa46 commit b3fc440
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions nltk/test/internals.doctest
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ perform the other method:
'yum'
>>> GoodEater1().batch_eat(['steak', 'peas'])
['yum', 'yum']

>>> class GoodEater2(EaterI):
... def batch_eat(self, foods):
... return ['yum' for food in foods]
Expand Down Expand Up @@ -79,12 +79,12 @@ It's ok to use intermediate abstract classes:
>>> class GoodEater3(AbstractEater):
... def eat(self, food):
... return 'yum'
...
...
>>> GoodEater3().eat('steak')
'yum'
>>> GoodEater3().batch_eat(['steak', 'peas'])
['yum', 'yum']

>>> class GoodEater4(AbstractEater):
... def batch_eat(self, foods):
... return ['yum' for food in foods]
Expand Down Expand Up @@ -122,19 +122,8 @@ Here's some extra tests:
>>> overridden(D().f)
True

overridden() can be called on unbound methods as well:

>>> overridden(A.f)
False
>>> overridden(B.f)
True
>>> overridden(C.f)
False
>>> overridden(D.f)
True

It works for classic classes, too:

>>> class A:
... def f(x): pass
>>> class B(A):
Expand All @@ -149,12 +138,3 @@ It works for classic classes, too:
False
>>> overridden(D().f)
True
>>> overridden(A.f)
False
>>> overridden(B.f)
True
>>> overridden(C.f)
False
>>> overridden(D.f)
True

0 comments on commit b3fc440

Please sign in to comment.