mirror of
https://github.com/evennia/evennia.git
synced 2026-03-20 06:46:31 +01:00
Fix unittests
This commit is contained in:
parent
bee7fa174d
commit
b571d6fdd4
2 changed files with 14 additions and 10 deletions
|
|
@ -670,7 +670,7 @@ class TestGenderSub(CommandTest):
|
|||
char = create_object(gendersub.GenderCharacter, key="Gendered", location=self.room1)
|
||||
txt = "Test |p gender"
|
||||
self.assertEqual(gendersub._RE_GENDER_PRONOUN.sub(char._get_pronoun, txt), "Test their gender")
|
||||
|
||||
|
||||
# test health bar contrib
|
||||
|
||||
from evennia.contrib import health_bar
|
||||
|
|
@ -798,7 +798,7 @@ from evennia.contrib import talking_npc
|
|||
class TestTalkingNPC(CommandTest):
|
||||
def test_talkingnpc(self):
|
||||
npc = create_object(talking_npc.TalkingNPC, key="npctalker", location=self.room1)
|
||||
self.call(talking_npc.CmdTalk(), "", "(You walk up and talk to Char.)|")
|
||||
self.call(talking_npc.CmdTalk(), "", "(You walk up and talk to Char.)")
|
||||
npc.delete()
|
||||
|
||||
|
||||
|
|
@ -966,7 +966,7 @@ class TestTurnBattleCmd(CommandTest):
|
|||
self.call(tb_basic.CmdPass(), "", "You can only do that in combat. (see: help fight)")
|
||||
self.call(tb_basic.CmdDisengage(), "", "You can only do that in combat. (see: help fight)")
|
||||
self.call(tb_basic.CmdRest(), "", "Char rests to recover HP.")
|
||||
|
||||
|
||||
# Test equipment commands
|
||||
def test_turnbattleequipcmd(self):
|
||||
# Start with equip module specific commands.
|
||||
|
|
@ -984,7 +984,7 @@ class TestTurnBattleCmd(CommandTest):
|
|||
self.call(tb_equip.CmdPass(), "", "You can only do that in combat. (see: help fight)")
|
||||
self.call(tb_equip.CmdDisengage(), "", "You can only do that in combat. (see: help fight)")
|
||||
self.call(tb_equip.CmdRest(), "", "Char rests to recover HP.")
|
||||
|
||||
|
||||
# Test range commands
|
||||
def test_turnbattlerangecmd(self):
|
||||
# Start with range module specific commands.
|
||||
|
|
@ -998,7 +998,7 @@ class TestTurnBattleCmd(CommandTest):
|
|||
self.call(tb_range.CmdPass(), "", "You can only do that in combat. (see: help fight)")
|
||||
self.call(tb_range.CmdDisengage(), "", "You can only do that in combat. (see: help fight)")
|
||||
self.call(tb_range.CmdRest(), "", "Char rests to recover HP.")
|
||||
|
||||
|
||||
|
||||
class TestTurnBattleFunc(EvenniaTest):
|
||||
|
||||
|
|
@ -1080,7 +1080,7 @@ class TestTurnBattleFunc(EvenniaTest):
|
|||
self.assertTrue(turnhandler.db.fighters == [joiner, attacker, defender])
|
||||
# Remove the script at the end
|
||||
turnhandler.stop()
|
||||
|
||||
|
||||
# Test the combat functions in tb_equip too. They work mostly the same.
|
||||
def test_tbequipfunc(self):
|
||||
attacker = create_object(tb_equip.TBEquipCharacter, key="Attacker")
|
||||
|
|
@ -1159,7 +1159,7 @@ class TestTurnBattleFunc(EvenniaTest):
|
|||
self.assertTrue(turnhandler.db.fighters == [joiner, attacker, defender])
|
||||
# Remove the script at the end
|
||||
turnhandler.stop()
|
||||
|
||||
|
||||
# Test combat functions in tb_range too.
|
||||
def test_tbrangefunc(self):
|
||||
testroom = create_object(DefaultRoom, key="Test Room")
|
||||
|
|
@ -1264,7 +1264,7 @@ Bar
|
|||
-Qux"""
|
||||
|
||||
class TestTreeSelectFunc(EvenniaTest):
|
||||
|
||||
|
||||
def test_tree_functions(self):
|
||||
# Dash counter
|
||||
self.assertTrue(tree_select.dashcount("--test") == 2)
|
||||
|
|
@ -1279,7 +1279,7 @@ class TestTreeSelectFunc(EvenniaTest):
|
|||
# Option list to menu options
|
||||
test_optlist = tree_select.parse_opts(TREE_MENU_TESTSTR, category_index=2)
|
||||
optlist_to_menu_expected_result = [{'goto': ['menunode_treeselect', {'newindex': 3}], 'key': 'Baz 1'},
|
||||
{'goto': ['menunode_treeselect', {'newindex': 4}], 'key': 'Baz 2'},
|
||||
{'goto': ['menunode_treeselect', {'newindex': 4}], 'key': 'Baz 2'},
|
||||
{'goto': ['menunode_treeselect', {'newindex': 1}], 'key': ['<< Go Back', 'go back', 'back'], 'desc': 'Return to the previous menu.'}]
|
||||
self.assertTrue(tree_select.optlist_to_menuoptions(TREE_MENU_TESTSTR, test_optlist, 2, True, True) == optlist_to_menu_expected_result)
|
||||
|
||||
|
|
|
|||
|
|
@ -976,7 +976,11 @@ class EvMenu(object):
|
|||
node (str): The formatted node to display.
|
||||
|
||||
"""
|
||||
screen_width = self._session.protocol_flags.get("SCREENWIDTH", {0: 78})[0]
|
||||
if self._session:
|
||||
screen_width = self._session.protocol_flags.get(
|
||||
"SCREENWIDTH", {0: _MAX_TEXT_WIDTH})[0]
|
||||
else:
|
||||
screen_width = _MAX_TEXT_WIDTH
|
||||
|
||||
nodetext_width_max = max(m_len(line) for line in nodetext.split("\n"))
|
||||
options_width_max = max(m_len(line) for line in optionstext.split("\n"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue