TST: move .str-test to strings.py & parametrize it; precursor to #23582
State: closed

- [x] precursor to #23582 and #23167
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

In #23582, I'm testing all string methods on all inferred dtypes (which uncovered lots of bugs that will be fixed by #23167 and follow-ups).

@jreback required #23582 to be broken up further, so here I'm moving one existing test that effectively uses the same idea to the (IMO) correct module (it's about testing the `.str`-accessor after all), where the `any_string_method` fixture can then be used for both the test I'm moving in this PR, and the tests I'm introducing in #23582.

It makes sense to have this fixture that's directly related to `.str` in the appropriate module, and not pollute the general `pandas/conftest.py` with it, that's mainly why I'm moving the test.


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Strings
description: String extension data type and string data

Comments:
Hello @h-vetinari! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/tests/series/test_api.py`](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/series/test_api.py) !

 - In the file [`pandas/tests/test_strings.py`](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py), following                are the PEP8 issues :
> [Line 30:12](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L30): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 30:26](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L30): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 31:12](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L31): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 33:15](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L33): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 33:29](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L33): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 34:17](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L34): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 34:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L34): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 35:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L35): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 35:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L35): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 36:15](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L36): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 36:34](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L36): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 37:15](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L37): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 37:34](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L37): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 38:17](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L38): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 38:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L38): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 39:16](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L39): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 39:37](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L39): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 40:16](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L40): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 40:37](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L40): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 41:19](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L41): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 41:37](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L41): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 42:13](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L42): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 42:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L42): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 43:16](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L43): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 43:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L43): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 44:12](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L44): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 44:28](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L44): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 47:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L47): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 47:29](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L47): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 48:13](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L48): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 48:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L48): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 49:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L49): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 49:29](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L49): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 50:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L50): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 50:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L50): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 51:18](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L51): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 51:32](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L51): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 52:12](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L52): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 52:29](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L52): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 53:18](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L53): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 53:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L53): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 54:18](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L54): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 54:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L54): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 55:15](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L55): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 55:28](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L55): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 56:16](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L56): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 56:35](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L56): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 57:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L57): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 57:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L57): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 58:15](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L58): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 58:29](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L58): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 59:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L59): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 59:29](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L59): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 60:19](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L60): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 60:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L60): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 61:19](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L61): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 61:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L61): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 62:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L62): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 62:31](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L62): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 63:36](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L63): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 64:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L64): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 64:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L64): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 65:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L65): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 65:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L65): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 66:19](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L66): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 66:30](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L66): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 68:18](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L68): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 68:36](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L68): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 69:13](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L69): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 69:28](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L69): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 70:14](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L70): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','
> [Line 70:29](https://github.com/h-vetinari/pandas/blob/95880280ee6541103c2582bf06cb05ca2bed8bb7/pandas/tests/test_strings.py#L70): [E241](https://duckduckgo.com/?q=pep8%20E241) multiple spaces after ','



Failure is rank segfault...
thanks @h-vetinari 
@jreback Thanks!
I think I'll have a celebratory drink tonight for my first PR that went straight through without having to incorporate review feedback. ;-)