Fixes Formatting Exception
State: closed

- [x] closes #25080
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

@MTKnife is this what you wanted?

Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string

Comments:
@TomAugspurger apologies, I should've tagged you as well. Does this fit what you wanted?
Nevermind, just remembered that _variables_ inside a try/except block can't be accessed outside of it. Fixing now.
Hello @EternalLearner42! Thanks for updating the PR.





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

##### Comment last updated on February 09, 2019 at 17:09 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25088?src=pr&el=h1) Report
> Merging [#25088](https://codecov.io/gh/pandas-dev/pandas/pull/25088?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/bb43726e1f52a0ddee45fcf485690719f262870d?src=pr&el=desc) will **decrease** coverage by `49.49%`.
> The diff coverage is `0%`.

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

```diff
@@            Coverage Diff             @@
##           master   #25088      +/-   ##
==========================================
- Coverage   92.37%   42.88%   -49.5%     
==========================================
  Files         166      166              
  Lines       52420    52423       +3     
==========================================
- Hits        48423    22479   -25944     
- Misses       3997    29944   +25947
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `42.88% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25088?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/terminal.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvdGVybWluYWwucHk=) | `20.48% <0%> (-0.77%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-99.35%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-95.46%)` | :arrow_down: |
| [pandas/io/sas/sas7bdat.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXM3YmRhdC5weQ==) | `0% <0%> (-91.17%)` | :arrow_down: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `0% <0%> (-90.15%)` | :arrow_down: |
| ... and [124 more](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree-more) | |

------

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

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25088?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@d7a0964`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `77.77%`.

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

```diff
@@            Coverage Diff            @@
##             master   #25088   +/-   ##
=========================================
  Coverage          ?    91.9%           
=========================================
  Files             ?      166           
  Lines             ?    52231           
  Branches          ?        0           
=========================================
  Hits              ?    48005           
  Misses            ?     4226           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.45% <77.77%> (?)` | |
| #single | `42.12% <11.11%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25088?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/terminal.py](https://codecov.io/gh/pandas-dev/pandas/pull/25088/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvdGVybWluYWwucHk=) | `32.53% <77.77%> (ø)` | |

------

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

Ok, I will fully admit - I do not understand what the loss of coverage means. I'm assuming it is negative. Can someone tell me how to fix that problem?
> Ok, I will fully admit - I do not understand what the loss of coverage means.

@EternalLearner42 : Don't worry about it.  Appreciate your concern though!
Just curious, is it possible to test this somehow on our CI?
I've been searching for the last half hour, and I cannot find anything to suggest how to tackle this test. How exactly can I replicate this? I can only think of creating a terminal console of an unknown size, but I don't know where to even begin with this. 

Can someone point me in the right direction?
you will want to use the monkeypatch fixture to mock the input to the function 
Well, I just made a commit... but I'm pretty sure it's terrible. I am competely new to making tests, as I said. Can you tell me how to improve this?
I'll push a test in a bit @EternalLearner42, mocking is a bit tricky.
Thanks! Meanwhile, is there anything else I can do? Unless I'm missing something, I've done everything that was requested
ok i think this test is good.
thanks @EternalLearner42