Fix Python2 test failures in certain locales
Check that we can also get the locale, after setting it, without raising an Exception.

- [x] closes #22129
- [x] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Hello @ginggs! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on August 11, 2018 at 08:35 Hours UTC https://travis-ci.org/pandas-dev/pandas/jobs/412589280#L3432

@ginggs : Good start!  Looks like you have some lint issues though. # [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22213?src=pr&el=h1) Report
> Merging [#22213](https://codecov.io/gh/pandas-dev/pandas/pull/22213?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/0370740034978d3a63d4b8e5e2c96ff54e7e08ba?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/22213/graphs/tree.svg?token=eZ4WkYLtcO&src=pr&height=150&width=650)](https://codecov.io/gh/pandas-dev/pandas/pull/22213?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #22213      +/-   ##
==========================================
+ Coverage   92.08%   92.08%   +<.01%     
==========================================
  Files         169      169              
  Lines       50694    50691       -3     
==========================================
- Hits        46682    46681       -1     
+ Misses       4012     4010       -2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.49% <100%> (ø)` | :arrow_up: |
| #single | `42.34% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22213?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/22213/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `86.06% <100%> (+0.16%)` | :arrow_up: |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/22213/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.75% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22213?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22213?src=pr&el=footer). Last update [0370740...6cceebc](https://codecov.io/gh/pandas-dev/pandas/pull/22213?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 I don't know how we can test this, since this change is making a test in pandas more robust against things external to pandas. Should be able to monkey patch getlocale:

https://docs.pytest.org/en/latest/monkeypatch.html Thanks!  I'll see what I can do. Hmm, I seem to have reproduced this in my branch migrating us to circleci 2.0: https://circleci.com/gh/pandas-dev/pandas/16656?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link (search for unknown locale). @TomAugspurger it seems you have a Debian Stretch container there, and the `locales-all` package is installed.

I'm still struggling to come up with a test case that is not too contrived. @WillAyd I've added two test cases, and verified that the second test fails without my changes to `pandas/util/testing.py`. These tests look good to me. Merging later today unless @WillAyd has other comments. @WillAyd updated using monkeypatch.context(). @WillAyd sorry, what is the question? @WillAyd reworked to drop the monkeypatch on `setlocale`, and added another test. Thanks @ginggs! Note, `monkeypatch.context` is new in pytest 3.6:
https://docs.pytest.org/en/latest/changelog.html#pytest-3-6-0-2018-05-23

We should update our minimum pytest in `ci/environment-dev.yaml`


On Mon, Aug 13, 2018 at 1:24 PM William Ayd <notifications@github.com>
wrote:

> Thanks @ginggs <https://github.com/ginggs>!
>
> —
> You are receiving this because you modified the open/close state.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/22213#issuecomment-412616597>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIueJ9BQA6ZZJsO6UuBsrvq9YwD9dks5uQcRlgaJpZM4VwLDD>
> .
>
 @TomAugspurger good point as that was discussed in https://github.com/pandas-dev/pandas/pull/21531#pullrequestreview-137045726 can submit a PR later today to bump @WillAyd you are welcome, and thanks for your patience! Just looking back here we probably want a whatsnew as well - @ginggs do you want to do that in a separate PR? Should be able to leverage the same `Development` section I am creating in #22320 @WillAyd sure, I can do that.  Do I wait until #22320 is merged? Probably easiest that way. Hope to have that merged in soon - thanks!