Skip to content

Commit

Permalink
this fixes #400
Browse files Browse the repository at this point in the history
fix call of `set_node_style` in `GraphMachine._get_graph`; makes sure the enum name or a string is passed; bump version
  • Loading branch information
aleneum committed Mar 25, 2020
1 parent 2b91ca1 commit 0a66a36
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.8.1 ()

Release 0.8.1 is a minor release of bugfixes in the diagram extension

- Bugfix #400: Fix style initialization when initial state is an `Enum` (thanks @kbinpgh)

## 0.8.0 (March 2020)

Release 0.8.0 is a major release and introduces asyncio support for Python 3.7+, parallel state support and some bugfixes
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# <a name="transitions-module"></a> transitions
[![Version](https://img.shields.io/badge/version-v0.8.0-orange.svg)](https://github.com/pytransitions/transitions)
[![Version](https://img.shields.io/badge/version-v0.8.1-orange.svg)](https://github.com/pytransitions/transitions)
[![Build Status](https://travis-ci.org/pytransitions/transitions.svg?branch=master)](https://travis-ci.org/pytransitions/transitions)
[![Coverage Status](https://coveralls.io/repos/pytransitions/transitions/badge.svg?branch=master&service=github)](https://coveralls.io/github/pytransitions/transitions?branch=master)
[![Pylint](https://img.shields.io/badge/pylint-9.71%2F10-green.svg)](https://github.com/pytransitions/transitions)
<!-- [![Pylint](https://img.shields.io/badge/pylint-9.71%2F10-green.svg)](https://github.com/pytransitions/transitions) -->
[![PyPi](https://img.shields.io/pypi/v/transitions.svg)](https://pypi.org/project/transitions)
[![GitHub commits](https://img.shields.io/github/commits-since/pytransitions/transitions/0.7.2.svg)](https://github.com/pytransitions/transitions/compare/0.7.2...master)
[![GitHub commits](https://img.shields.io/github/commits-since/pytransitions/transitions/0.8.0.svg)](https://github.com/pytransitions/transitions/compare/0.8.0...master)
[![License](https://img.shields.io/github/license/pytransitions/transitions.svg)](LICENSE)
<!--[![Name](Image)](Link)-->

Expand Down
8 changes: 8 additions & 0 deletions tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,11 @@ def test_initial_enum(self):
m1 = self.machine_cls(states=self.States, initial=self.States.GREEN)
self.assertEqual(self.States.GREEN, m1.state)
self.assertEqual(m1.state.name, self.States.GREEN.name)


@skipIf(enum is None, "enum is not available")
class TestEnumWithGraph(TestEnumsAsStates):

def setUp(self):
super(TestEnumWithGraph, self).setUp()
self.machine_cls = MachineFactory.get_predefined(graph=True)
3 changes: 2 additions & 1 deletion transitions/extensions/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def _get_graph(self, model, title=None, force_new=False, show_roi=False):
grph = self.graph_cls(self, title=title if title is not None else self.title)
self.model_graphs[model] = grph
try:
self.model_graphs[model].set_node_style(getattr(model, self.model_attribute), 'active')
state = getattr(model, self.model_attribute)
self.model_graphs[model].set_node_style(state.name if hasattr(state, 'name') else state, 'active')
except AttributeError:
_LOGGER.info("Could not set active state of diagram")
try:
Expand Down
2 changes: 1 addition & 1 deletion transitions/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
to determine transitions's version during runtime.
"""

__version__ = '0.8.0'
__version__ = '0.8.1'

0 comments on commit 0a66a36

Please sign in to comment.