コード例 #1
0
class TestBeginner(TestCase):
    def setUp(self):
        self.beginner_player = Beginner('User2')

    def test_attributes_are_set(self):
        self.assertEqual('User2', self.beginner_player.username)
        self.assertEqual(50, self.beginner_player.health)

    def test_set_username_with_empty_string__raises(self):
        with self.assertRaises(ValueError) as ex:
            self.beginner_player.username(player=Beginner(""))
        self.assertEqual("Player's username cannot be an empty string.",
                         str(ex.exception))

    def test_set_username(self):
        player_2 = Beginner("Bil")
        self.assertEqual("Bil", player_2.username)

    def test_check_class_name(self):
        self.assertEqual("Beginner", self.beginner_player.__class__.__name__)
コード例 #2
0
ファイル: test_beginner.py プロジェクト: jgronowski/PythonOOP
 def test_set_new_username_should_change_players_username(self):
     player = Beginner("Peter")
     player.username = "******"
     self.assertEqual(player.username, "George")
コード例 #3
0
ファイル: test_beginner.py プロジェクト: jgronowski/PythonOOP
 def test_set_empty_string_username_should_raise_error(self):
     player = Beginner("Peter")
     with self.assertRaises(ValueError):
         player.username = ""
コード例 #4
0
 def test_username_setter(self):
     beg = Beginner('test')
     beg.username = '******'
     self.assertEqual('new', beg.username)
コード例 #5
0
 def test_username_raise(self):
     beg = Beginner('test')
     with self.assertRaises(ValueError) as ex:
         beg.username = ''
     self.assertEqual(str(ex.exception),
                      'Player\'s username cannot be an empty string.')
コード例 #6
0
ファイル: test_beginner.py プロジェクト: MeGaDeTH91/SoftUni
    def test_username_invalid_data_should_raise_error(self):
        player = Beginner("Dave")

        with self.assertRaises(ValueError):
            player.username = ""
コード例 #7
0
ファイル: test_beginner.py プロジェクト: MeGaDeTH91/SoftUni
    def test_username_valid_data_should_work_correctly(self):
        player = Beginner("Dave")
        player.username = "******"

        self.assertEqual(player.username, "Cool")
コード例 #8
0
 def test_username_change(self):
     a = Beginner("test")
     a.username = '******'
     self.assertEqual(a.username, 'new name')