Skip to content
This repository was archived by the owner on Feb 11, 2023. It is now read-only.

Commit 9dc73cb

Browse files
committed
Fix tests, fix hookery dependency spec
Bump version: 1.33.0 → 1.34.0
1 parent c6ccee8 commit 9dc73cb

7 files changed

Lines changed: 21 additions & 14 deletions

File tree

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.33.0
2+
current_version = 1.34.0
33
commit = true
44
tag = false
55

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
The MIT License (MIT)
33

4-
Copyright (c) 2017 Jazeps Basko
4+
Copyright (c) 2017-2018 Jazeps Basko
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Main Features
1515
* Any depth of sections allowed
1616
* INI (ConfigParser), JSON, YAML formats
1717
* click framework integration
18-
* Designed for humans
1918

2019

2120
Documentation

configmanager/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '1.33.0'
1+
__version__ = '1.34.0'
22

33
from .managers import Config
44
from .items import Item

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
six ==1.10.0
55
future ==0.16.0
6-
hookery >=1.1.1, <=2.0.0
6+
hookery == 1.4.0
77

88
#
99
# Potentially optional dependencies

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def read(fname):
2626
description='Forget about configparser, YAML, or JSON parsers. Focus on configuration.',
2727
long_description=read('README.rst'),
2828
packages=['configmanager'],
29-
install_requires=['six==1.10.0', 'future==0.16.0', 'configparser==3.5.0', 'hookery >=1.1.1, <=2.0.0'],
29+
install_requires=['six==1.10.0', 'future==0.16.0', 'configparser==3.5.0', 'hookery == 1.4.0'],
3030
extras_require={
3131
'yaml': ['PyYAML'],
3232
'click': ['click'],

tests/test_hooks.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
from configmanager.utils import not_set
55

66

7+
def sub_dict(dct, keys):
8+
"""
9+
Helper for tests that creates a dictionary from the given dictionary
10+
with just the listed keys included.
11+
"""
12+
return {k: dct[k] for k in keys if k in dct}
13+
14+
715
def test_hooks_available_on_all_sections():
816
config = Config({
917
'uploads': {
@@ -30,11 +38,11 @@ def test_not_found_hook():
3038

3139
@config.hooks.not_found
3240
def first_hook(*args, **kwargs):
33-
calls.append(('first', args, kwargs))
41+
calls.append(('first', args, sub_dict(kwargs, ('section', 'name'))))
3442

3543
@config.hooks.not_found
3644
def second_hook(*args, **kwargs):
37-
calls.append(('second', args, kwargs))
45+
calls.append(('second', args, sub_dict(kwargs, ('section', 'name'))))
3846

3947
assert len(calls) == 0
4048

@@ -56,7 +64,7 @@ def second_hook(*args, **kwargs):
5664
# the hook handlers again, including any subsequent hook handlers as part of current event.
5765
@config.hooks.not_found
5866
def third_hook(*args, **kwargs):
59-
calls.append(('third', args, kwargs))
67+
calls.append(('third', args, sub_dict(kwargs, ('section', 'name'))))
6068

6169
assert kwargs['section']
6270
assert kwargs['name']
@@ -68,7 +76,7 @@ def third_hook(*args, **kwargs):
6876
# Fourth hook will never be called because the third hook already resolves the missing name
6977
@config.hooks.not_found
7078
def fourth_hook(*args, **kwargs):
71-
calls.append(('fourth', args, kwargs))
79+
calls.append(('fourth', args, sub_dict(kwargs, ('section', 'name'))))
7280

7381
assert len(calls) == 4
7482

@@ -98,11 +106,11 @@ def test_item_added_to_section_hook():
98106

99107
@config.hooks.item_added_to_section
100108
def item_added_to_section(*args, **kwargs):
101-
calls.append(('first', args, kwargs))
109+
calls.append(('first', args, sub_dict(kwargs, ('section', 'subject', 'alias'))))
102110

103111
@config.hooks.item_added_to_section
104112
def item_added_to_section2(*args, **kwargs):
105-
calls.append(('second', args, kwargs))
113+
calls.append(('second', args, sub_dict(kwargs, ('section', 'subject', 'alias'))))
106114

107115
assert calls == []
108116

@@ -191,11 +199,11 @@ def test_section_added_to_section_hook():
191199

192200
@config.hooks.section_added_to_section
193201
def section_added_to_section1(*args, **kwargs):
194-
calls.append(('on_root', args, kwargs))
202+
calls.append(('on_root', args, sub_dict(kwargs, ('section', 'subject', 'alias'))))
195203

196204
@config.uploads.hooks.section_added_to_section
197205
def section_added_to_section2(*args, **kwargs):
198-
calls.append(('on_uploads', args, kwargs))
206+
calls.append(('on_uploads', args, sub_dict(kwargs, ('section', 'subject', 'alias'))))
199207

200208
assert calls == []
201209

0 commit comments

Comments
 (0)