Skip to content

Commit

Permalink
refactoring. 2.1.1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
eumis committed Jun 4, 2019
1 parent 4a8672a commit 3446935
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## 2.1.1

- added call modifier to package core

## 2.1.0

- used pytest for unit tests
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -45,8 +45,8 @@ def _get_version() -> str:

def _get_long_description():
readme_path = join_path(_HERE, "README.md")
with codecs.open(readme_path, encoding="utf-8") as f:
return "\n" + f.read()
with codecs.open(readme_path, encoding="utf-8") as readme:
return "\n" + readme.read()


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tkviews/__init__.py
@@ -1,6 +1,6 @@
"""Package adapts pyviews for using with tkinter"""

__version__ = '2.1.0'
__version__ = '2.1.1'

from .core import PackGeometry, GridGeometry, PlaceGeometry

Expand Down
58 changes: 29 additions & 29 deletions tkviews/core/tests/geometry_tests.py
Expand Up @@ -9,7 +9,7 @@
def geometry_fixture(request):
widget = Mock()
widget.grid = Mock(grid_forget=Mock(), pack_forget=Mock())
request.cls._widget = widget
request.cls.widget = widget


@mark.usefixtures('geometry_fixture')
Expand All @@ -20,19 +20,19 @@ def test_apply(self):
"""should call grid method of widget"""
geometry = GridGeometry()

geometry.apply(self._widget)
geometry.apply(self.widget)

assert self._widget.grid.called
assert self._widget.grid.call_count == 1
assert self.widget.grid.called
assert self.widget.grid.call_count == 1

def test_forget(self):
"""should call grid_forget method of widget"""
geometry = GridGeometry()

geometry.forget(self._widget)
geometry.forget(self.widget)

assert self._widget.grid_forget.called
assert self._widget.grid_forget.call_count == 1
assert self.widget.grid_forget.called
assert self.widget.grid_forget.call_count == 1

@mark.parametrize('args', [
{},
Expand All @@ -42,9 +42,9 @@ def test_init(self, args):
"""grid should be called with arguments passed to geometry"""
geometry = GridGeometry(**args)

geometry.apply(self._widget)
geometry.apply(self.widget)

assert self._widget.grid.call_args == call(**args)
assert self.widget.grid.call_args == call(**args)

@mark.parametrize('args', [
{'row': 1},
Expand All @@ -58,8 +58,8 @@ def test_set(self, args):
for key, value in args.items():
geometry.set(key, value)

geometry.apply(self._widget)
assert self._widget.grid.call_args == call(**args)
geometry.apply(self.widget)
assert self.widget.grid.call_args == call(**args)


@mark.usefixtures('geometry_fixture')
Expand All @@ -70,18 +70,18 @@ def test_apply(self):
"""apply() should call pack method of widget"""
geometry = PackGeometry()

geometry.apply(self._widget)
geometry.apply(self.widget)

assert self._widget.pack.called
assert self._widget.pack.call_count == 1
assert self.widget.pack.called
assert self.widget.pack.call_count == 1

def test_forget(self):
"""forget() should call pack_forget method of widget"""
geometry = PackGeometry()

geometry.forget(self._widget)
geometry.forget(self.widget)

assert self._widget.pack_forget.called
assert self.widget.pack_forget.called

@mark.parametrize('args', [
{},
Expand All @@ -91,9 +91,9 @@ def test_init(self, args):
"""__init__() should call Widget.pack() with arguments passed to geometry"""
geometry = PackGeometry(**args)

geometry.apply(self._widget)
geometry.apply(self.widget)

assert self._widget.pack.call_args == call(**args)
assert self.widget.pack.call_args == call(**args)

@mark.parametrize('args', [
{'expand': True},
Expand All @@ -107,8 +107,8 @@ def test_set(self, args):
for key, value in args.items():
geometry.set(key, value)

geometry.apply(self._widget)
assert self._widget.pack.call_args == call(**args)
geometry.apply(self.widget)
assert self.widget.pack.call_args == call(**args)


@mark.usefixtures('geometry_fixture')
Expand All @@ -119,18 +119,18 @@ def test_apply(self):
"""apply() should call pack method of widget"""
geometry = PlaceGeometry()

geometry.apply(self._widget)
geometry.apply(self.widget)

assert self._widget.place.called
assert self._widget.place.call_count == 1
assert self.widget.place.called
assert self.widget.place.call_count == 1

def test_forget(self):
"""forget() should call place_forget method of widget"""
geometry = PlaceGeometry()

geometry.forget(self._widget)
geometry.forget(self.widget)

assert self._widget.place_forget.called
assert self.widget.place_forget.called

@mark.parametrize('args', [
{},
Expand All @@ -140,9 +140,9 @@ def test_init(self, args):
"""__init__() should call Widget.place() with arguments passed to geometry"""
geometry = PlaceGeometry(**args)

geometry.apply(self._widget)
geometry.apply(self.widget)

assert self._widget.place.call_args == call(**args)
assert self.widget.place.call_args == call(**args)

@mark.parametrize('args', [
{'expand': True},
Expand All @@ -156,5 +156,5 @@ def test_set(self, args):
for key, value in args.items():
geometry.set(key, value)

geometry.apply(self._widget)
assert self._widget.place.call_args == call(**args)
geometry.apply(self.widget)
assert self.widget.place.call_args == call(**args)
1 change: 0 additions & 1 deletion tkviews/node/tests/canvas_tests.py
@@ -1,4 +1,3 @@
from unittest import TestCase
from unittest.mock import Mock, call

from pytest import fixture, mark
Expand Down
2 changes: 1 addition & 1 deletion tkviews/node/ttk.py
Expand Up @@ -46,7 +46,7 @@ def full_name(self):
if self._parent_name else self.name


def theme_use(_: Node, key: str, __: Any):
def theme_use(_node: Node, key: str, _value: Any):
"""Sets ttk style theme"""
ttk_style = Style()
ttk_style.theme_use(key)
3 changes: 2 additions & 1 deletion tkviews/rendering/tests/ttk_tests.py
Expand Up @@ -33,11 +33,12 @@ def test_setup_value_setter_sets_name():

assert node.name == name

@staticmethod
@mark.parametrize('values', [
({'key': 'value'}),
({'key': 'value', 'another_key': 1})
])
def test_setup_value_setter_sets_values(self, values: dict):
def test_setup_value_setter_sets_values(values: dict):
"""should set setter that sets to "values" property"""
node = TtkStyle(Mock())

Expand Down

0 comments on commit 3446935

Please sign in to comment.