Add unittests for gendersub contrib as per #1105.
This commit is contained in:
parent
1b9016d26a
commit
7e762245c8
2 changed files with 26 additions and 12 deletions
|
|
@ -12,18 +12,18 @@ When in use, all messages being sent to the character will make use of
|
||||||
the character's gender, for example the echo
|
the character's gender, for example the echo
|
||||||
|
|
||||||
```
|
```
|
||||||
char.msg("%s falls on {p face with a thud." % char.key)
|
char.msg("%s falls on |p face with a thud." % char.key)
|
||||||
```
|
```
|
||||||
|
|
||||||
will result in "Tom falls on his|her|its face with a thud" depending
|
will result in "Tom falls on his|her|its|their face with a thud"
|
||||||
on the gender of the object being messaged. Default gender is
|
depending on the gender of the object being messaged. Default gender
|
||||||
"neutral".
|
is "ambiguous" (they).
|
||||||
|
|
||||||
To use, have DefaultCharacter inherit from this, or change
|
To use, have DefaultCharacter inherit from this, or change
|
||||||
setting.DEFAULT_CHARACTER to point to this class.
|
setting.DEFAULT_CHARACTER to point to this class.
|
||||||
|
|
||||||
The `@gender` command needs to be added to the default cmdset
|
The `@gender` command needs to be added to the default cmdset before
|
||||||
before it becomes available.
|
it becomes available.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ _GENDER_PRONOUN_MAP = {"male": {"s": "he",
|
||||||
"p": "their",
|
"p": "their",
|
||||||
"a": "theirs"}
|
"a": "theirs"}
|
||||||
}
|
}
|
||||||
_RE_GENDER_PRONOUN = re.compile(r'({s|{S|{o|{O|{p|{P|{a|{A)')
|
_RE_GENDER_PRONOUN = re.compile(r'(\|s|\|S|\|o|\|O|\|p|\|P|\|a|\|A)')
|
||||||
|
|
||||||
# in-game command for setting the gender
|
# in-game command for setting the gender
|
||||||
|
|
||||||
|
|
@ -103,10 +103,10 @@ class GenderCharacter(DefaultCharacter):
|
||||||
regex_match (MatchObject): the regular expression match.
|
regex_match (MatchObject): the regular expression match.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- `{s`, `{S`: Subjective form: he, she, it, He, She, It, They
|
- `|s`, `|S`: Subjective form: he, she, it, He, She, It, They
|
||||||
- `{o`, `{O`: Objective form: him, her, it, Him, Her, It, Them
|
- `|o`, `|O`: Objective form: him, her, it, Him, Her, It, Them
|
||||||
- `{p`, `{P`: Possessive form: his, her, its, His, Her, Its, Their
|
- `|p`, `|P`: Possessive form: his, her, its, His, Her, Its, Their
|
||||||
- `{a`, `{A`: Absolute Possessive form: his, hers, its, His, Hers, Its, Theirs
|
- `|a`, `|A`: Absolute Possessive form: his, hers, its, His, Hers, Its, Theirs
|
||||||
|
|
||||||
"""
|
"""
|
||||||
typ = regex_match.group()[1] # "s", "O" etc
|
typ = regex_match.group()[1] # "s", "O" etc
|
||||||
|
|
|
||||||
|
|
@ -504,3 +504,17 @@ class TestEmailLogin(CommandTest):
|
||||||
self.call(email_login.CmdUnconnectedLook(), "", "==========")
|
self.call(email_login.CmdUnconnectedLook(), "", "==========")
|
||||||
def test_unconnectedhelp(self):
|
def test_unconnectedhelp(self):
|
||||||
self.call(email_login.CmdUnconnectedHelp(), "", "You are not yet logged into the game.")
|
self.call(email_login.CmdUnconnectedHelp(), "", "You are not yet logged into the game.")
|
||||||
|
|
||||||
|
# test gendersub contrib
|
||||||
|
|
||||||
|
from evennia.contrib import gendersub
|
||||||
|
|
||||||
|
class TestGenderSub(CommandTest):
|
||||||
|
def test_setgender(self):
|
||||||
|
self.call(gendersub.SetGender(), "male", "Your gender was set to male.")
|
||||||
|
self.call(gendersub.SetGender(), "ambiguous", "Your gender was set to ambiguous.")
|
||||||
|
self.call(gendersub.SetGender(), "Foo", "Usage: @gender")
|
||||||
|
def test_gendercharacter(self):
|
||||||
|
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")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue