Skip to content

Instantly share code, notes, and snippets.

@Ah-da-Coder
Created September 7, 2019 14:56
Show Gist options
  • Select an option

  • Save Ah-da-Coder/a75426f752126ed1c6ef924914ebe8fa to your computer and use it in GitHub Desktop.

Select an option

Save Ah-da-Coder/a75426f752126ed1c6ef924914ebe8fa to your computer and use it in GitHub Desktop.
Stateパターンのテストコード
import unittest
from src.state import Context
class StateTest(unittest.TestCase):
def setUp(self):
self.context = Context()
def test_initial_state(self):
state = self.context.state
self.assertEqual(state.action_name, "起きる")
self.assertEqual(state.greeting_word, "おはよう")
def test_change_state(self):
state = self.context.state
self.assertEqual(state.action_name, "起きる")
self.context.change_state("一日の終わり")
state = self.context.state
self.assertEqual(state.action_name, "寝る")
def test_not_registered_state_raise_exception(self):
with self.assertRaises(ValueError):
self.context.change_state("登録されていないステート")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment