@@ -111,31 +111,37 @@ def test_as_text(value, expects):
111111 assert words .as_text (value ) == expects
112112
113113
114- def test_word_join ():
115- assert words .word_join ([]) == ''
116-
117- assert words .word_join (["bob" ]) == "bob"
118- assert words .word_join (["bob" , "alice" ]) == "bob and alice"
119- assert words .word_join (["bob" , "alice" , "fred" ]) == "bob, alice and fred"
120-
121- assert words .word_join (["bob" ], use_repr = True ) == "'bob'"
122- assert words .word_join (["bob" , "alice" ], use_repr = True ) == "'bob' and 'alice'"
123- assert words .word_join (["bob" , "alice" , "fred" ], use_repr = True ) == "'bob', 'alice' and 'fred'"
124-
125- assert words .word_join (["bob" ], use_repr = True , oxford = True ) == "'bob'"
126- assert words .word_join (["bob" , "alice" ], use_repr = True , oxford = True ) == "'bob' and 'alice'"
127- assert words .word_join (["bob" , "alice" , "fred" ], use_repr = True , oxford = True ) == "'bob', 'alice', and 'fred'"
128-
129- assert words .word_join (()) == ''
130-
131- assert words .word_join (("bob" , )) == "bob"
132- assert words .word_join (("bob" , "alice" )) == "bob and alice"
133- assert words .word_join (("bob" , "alice" , "fred" )) == "bob, alice and fred"
134-
135- assert words .word_join (("bob" , ), use_repr = True ) == "'bob'"
136- assert words .word_join (("bob" , "alice" ), use_repr = True ) == "'bob' and 'alice'"
137- assert words .word_join (("bob" , "alice" , "fred" ), use_repr = True ) == "'bob', 'alice' and 'fred'"
138-
139- assert words .word_join (("bob" , ), use_repr = True , oxford = True ) == "'bob'"
140- assert words .word_join (("bob" , "alice" ), use_repr = True , oxford = True ) == "'bob' and 'alice'"
141- assert words .word_join (("bob" , "alice" , "fred" ), use_repr = True , oxford = True ) == "'bob', 'alice', and 'fred'"
114+ @pytest .mark .parametrize (
115+ "args, kwargs, expects" ,
116+ [
117+ (([], ), {}, '' ),
118+ (((), ), {}, '' ),
119+ ((["bob" ], ), {}, "bob" ),
120+ ((["bob" , "alice" ], ), {}, "bob and alice" ),
121+ ((["bob" , "alice" , "fred" ], ), {}, "bob, alice and fred" ),
122+ ((("bob" , ), ), {}, "bob" ),
123+ ((("bob" , "alice" ), ), {}, "bob and alice" ),
124+ ((("bob" , "alice" , "fred" ), ), {}, "bob, alice and fred" ),
125+ ((("bob" , ), ), {"delimiter" : ';' }, "bob" ),
126+ ((("bob" , "alice" ), ), {"delimiter" : ';' }, "bob and alice" ),
127+ ((("bob" , "alice" , "fred" ), ), {"delimiter" : ';' }, "bob; alice and fred" ),
128+ ((["bob" ], ), {"use_repr" : True }, "'bob'" ),
129+ ((["bob" , "alice" ], ), {"use_repr" : True }, "'bob' and 'alice'" ),
130+ ((["bob" , "alice" , "fred" ], ), {"use_repr" : True }, "'bob', 'alice' and 'fred'" ),
131+ ((("bob" , ), ), {"use_repr" : True }, "'bob'" ),
132+ ((("bob" , "alice" ), ), {"use_repr" : True }, "'bob' and 'alice'" ),
133+ ((("bob" , "alice" , "fred" ), ), {"use_repr" : True }, "'bob', 'alice' and 'fred'" ),
134+ ((["bob" ], ), {"use_repr" : True , "oxford" : True }, "'bob'" ),
135+ ((["bob" , "alice" ], ), {"use_repr" : True , "oxford" : True }, "'bob' and 'alice'" ),
136+ ((["bob" , "alice" , "fred" ], ), {"use_repr" : True , "oxford" : True }, "'bob', 'alice', and 'fred'" ),
137+ ((["bob" , "alice" , "fred" ], ), {"use_repr" : True , "oxford" : True , "delimiter" : ';' },
138+ "'bob'; 'alice'; and 'fred'" ),
139+ ((["bob" , "alice" , "fred" ], ), {"use_repr" : True , "oxford" : True , "connective" : 'or' },
140+ "'bob', 'alice', or 'fred'" ),
141+ ((("bob" , ), ), {"use_repr" : True , "oxford" : True }, "'bob'" ),
142+ ((("bob" , "alice" ), ), {"use_repr" : True , "oxford" : True }, "'bob' and 'alice'" ),
143+ ((("bob" , "alice" , "fred" ), ), {"use_repr" : True , "oxford" : True }, "'bob', 'alice', and 'fred'" ),
144+ ]
145+ )
146+ def test_word_join (args , kwargs , expects ):
147+ assert words .word_join (* args , ** kwargs ) == expects
0 commit comments