TST: Skip if Decorators for Localpath and Pathlib
State: closed

- [ ] progress towards #18190 
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

This push should knock out the ``pathlib`` and ``localpath`` skip if functions. Rather than creating them as their own marks, I've created a generic decorator that accepts a package and optionally a min_version as its arguments. With that, it returns a function marked with the ``skip_if`` decorator that calls ``safe_import`` to validate whether or not the function should be skipped.

This isn't applicable to all of the skip_if decorators because some of them have post-processing they do after import (see the matplotlib decorators) but for very generic import checks this could scale better in the future

Labels:
name: Testing
description: pandas testing functions or related to the test suite

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18765?src=pr&el=h1) Report
> Merging [#18765](https://codecov.io/gh/pandas-dev/pandas/pull/18765?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5b9b4a89c9bf6ca23aa4431973d67da6df50ced9?src=pr&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #18765      +/-   ##
==========================================
- Coverage   91.62%   91.61%   -0.02%     
==========================================
  Files         154      153       -1     
  Lines       51427    51359      -68     
==========================================
- Hits        47122    47052      -70     
- Misses       4305     4307       +2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.47% <100%> (-0.01%)` | :arrow_down: |
| #single | `40.76% <100%> (-0.17%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18765?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/18765/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `82.91% <ø> (+0.38%)` | :arrow_up: |
| [pandas/util/\_test\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/18765/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX3Rlc3RfZGVjb3JhdG9ycy5weQ==) | `93.87% <100%> (+0.54%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/18765/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/core/sparse/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18765/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3BhcnNlL2ZyYW1lLnB5) | `94.78% <0%> (-0.03%)` | :arrow_down: |
| [pandas/core/apply.py](https://codecov.io/gh/pandas-dev/pandas/pull/18765/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXBwbHkucHk=) | | |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/18765/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.81% <0%> (+0.02%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18765?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/18765?src=pr&el=footer). Last update [5b9b4a8...53d5737](https://codecov.io/gh/pandas-dev/pandas/pull/18765?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jreback one failure on travis but it doesn't look related. Everything else green
thanks!