Skip to content

Commit 827413d

Browse files
authored
Merge pull request #4 from nocarryr/expand-tested-pyversions
Expand tested pyversions
2 parents 7ff6ba0 + ead7e21 commit 827413d

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

.travis.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,21 @@ matrix:
1111
- ALLOW_DEPLOY=false
1212
- AIO_AVAILABLE=false
1313
- COVERAGERC=".coveragerc-py34"
14-
- python: "3.5.2"
14+
- python: "3.5"
1515
env:
16-
- ALLOW_DEPLOY=true
16+
- ALLOW_DEPLOY=false
17+
- AIO_AVAILABLE=false
18+
- COVERAGERC=".coveragerc"
19+
- python: "3.6"
20+
env:
21+
- ALLOW_DEPLOY=false
22+
- AIO_AVAILABLE=true
23+
- COVERAGERC=".coveragerc"
24+
- python: "3.7"
25+
dist: xenial
26+
sudo: required
27+
env:
28+
- ALLOW_DEPLOY=false
1729
- AIO_AVAILABLE=true
1830
- COVERAGERC=".coveragerc"
1931
install:
@@ -32,7 +44,7 @@ deploy:
3244
provider: pypi
3345
distributions: sdist bdist_wheel
3446
on:
35-
python: "3.5.2"
47+
python: "3.6"
3648
tags: true
3749
user: nocarryr
3850
password:

pydispatch/dispatch.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ class Foo(Dispatcher):
8484
__skip_initialized = True
8585
def __new__(cls, *args, **kwargs):
8686
def iter_bases(_cls):
87-
if _cls is object:
88-
raise StopIteration
89-
yield _cls
90-
for b in _cls.__bases__:
91-
for _cls_ in iter_bases(b):
92-
yield _cls_
87+
if _cls is not object:
88+
yield _cls
89+
for b in _cls.__bases__:
90+
for _cls_ in iter_bases(b):
91+
yield _cls_
9392
skip_initialized = Dispatcher._Dispatcher__skip_initialized
9493
if not skip_initialized or cls not in Dispatcher._Dispatcher__initialized_subclasses:
9594
props = {}

tests/test_subclass_init.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
import math
22
import time
3+
import warnings
4+
5+
def test_dispatcher_construction():
6+
from pydispatch import Dispatcher, Property
7+
8+
class A(Dispatcher):
9+
foo = Property()
10+
bar = Property()
11+
baz = Property()
12+
_events_ = [
13+
'on_stuff', 'on_more_stuff',
14+
]
15+
class B(A):
16+
a = Property()
17+
b = Property()
18+
c = Property()
19+
_events_ = [
20+
'on_even_more_stuff', 'on_one_more_thing'
21+
]
22+
23+
with warnings.catch_warnings(record=True) as w_list:
24+
warnings.simplefilter("always")
25+
a = A()
26+
b = B()
27+
for w in w_list:
28+
# Check for PEP-0479 (StopIteration) issues
29+
assert not issubclass(w.category, DeprecationWarning)
30+
assert not issubclass(w.category, PendingDeprecationWarning)
31+
assert len(w_list) == 0
32+
33+
a_prop_names = {'foo', 'bar', 'baz'}
34+
a_event_names = {'on_stuff', 'on_more_stuff'}
35+
assert a_prop_names == set(a._Dispatcher__property_events.keys())
36+
assert a_event_names == set(a._Dispatcher__events.keys())
37+
38+
b_prop_names = {'a', 'b', 'c'}
39+
b_prop_names |= a_prop_names
40+
b_event_names = {'on_even_more_stuff', 'on_one_more_thing'}
41+
b_event_names |= a_event_names
42+
43+
assert b_prop_names == set(b._Dispatcher__property_events.keys())
44+
assert b_event_names == set(b._Dispatcher__events.keys())
345

446
def test_subclass_new_timing():
547
from pydispatch import Dispatcher, Property

0 commit comments

Comments
 (0)