Skip to content

Commit

Permalink
Allow renaming to identity
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Jan 19, 2016
1 parent a240df2 commit f0e3f15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions sismic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ def rename_state(self, old_name: str, new_name: str):
:param old_name: old name of the state
:param new_name: new name of the state
"""
if old_name == new_name:
return
if new_name in self._states:
raise StatechartError('State {} already exists!'.format(new_name))
state = self._states[old_name]
Expand Down
3 changes: 1 addition & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ def test_rename_unexisting_state(self):
self.sc.rename_state('unknown', 's3')

def test_do_not_change_name(self):
with self.assertRaises(exceptions.StatechartError):
self.sc.rename_state('s2', 's2')
self.sc.rename_state('s2', 's2')

def test_rename_to_an_existing_state(self):
with self.assertRaises(exceptions.StatechartError):
Expand Down

0 comments on commit f0e3f15

Please sign in to comment.