Repository: pandas-dev/pandas
Pull request: TST: Create test for #30122 about display.precision
- [x] closes #30122 
- [x] tests added / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit) for how to run them
- [ ] whatsnew entry


Problem statement:
setting precision for display sometimes shows wrong output
#### Code Sample, a copy-pastable example if possible

```python
pd.set_option("display.precision", 0)
pd.DataFrame([9.5444])

```
#### Problem description

The output is expected to be 10, but it shows 1.

#### Expected Output
    	0
    0	10
#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit           : None
python           : 3.7.3.final.0
python-bits      : 64
OS               : Windows
OS-release       : 10
machine          : AMD64
processor        : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder        : little
LC_ALL           : None
LANG             : None
LOCALE           : None.None

pandas           : 0.25.3
numpy            : 1.16.4
pytz             : 2019.1
dateutil         : 2.8.0
pip              : 19.1.1
setuptools       : 41.0.1
Cython           : 0.29.12
pytest           : 5.0.1
hypothesis       : None
sphinx           : 2.1.2
blosc            : None
feather          : None
xlsxwriter       : 1.1.8
lxml.etree       : 4.3.4
html5lib         : 1.0.1
pymysql          : None
psycopg2         : None
jinja2           : 2.10.1
IPython          : 7.6.1
pandas_datareader: None
bs4              : 4.7.1
bottleneck       : 1.2.1
fastparquet      : None
gcsfs            : None
lxml.etree       : 4.3.4
matplotlib       : 3.1.0
numexpr          : 2.6.9
odfpy            : None
openpyxl         : 2.6.2
pandas_gbq       : None
pyarrow          : None
pytables         : None
s3fs             : None
scipy            : 1.2.1
sqlalchemy       : 1.3.5
tables           : 3.5.2
xarray           : None
xlrd             : 1.2.0
xlwt             : 1.3.0
xlsxwriter       : 1.1.8
</details>

Hints from issue discussion:
will take a look at it at SprintSeoul year-end sprint.
This looks fixed on master. Could use a test

```
In [1]: pd.set_option("display.precision", 0)
   ...: pd.DataFrame([9.5444])
Out[1]:
    0
0  10
```
take

Commit message: TST: Create test for #30122 about display.precision

Patch to review:
diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py
index bf0a10fa702a5..2d5d3c9e0437c 100644
--- a/pandas/tests/io/formats/test_format.py
+++ b/pandas/tests/io/formats/test_format.py
@@ -2874,6 +2874,18 @@ def test_output_display_precision_trailing_zeroes(self):
             expected_output = "0     840\n1    4200\ndtype: float64"
             assert str(s) == expected_output
 
+    @pytest.mark.parametrize(
+        "value", [[9.4444], [0.49], [10.9999], [9.5444, 9.6], [0.46, 0.78, -9.9999]]
+    )
+    def test_set_option_precision(self, value):
+        # Issue #30122
+        # Precision was incorrectly shown
+
+        with option_context("display.precision", 0):
+
+            df = DataFrame(value)
+            assert str(df) == str(DataFrame(value).round(1))
+
     def test_output_significant_digits(self):
         # Issue #9764
 


Code review comments:
diff_hunk: @@ -2874,6 +2874,18 @@ def test_output_display_precision_trailing_zeroes(self):
             expected_output = "0     840\n1    4200\ndtype: float64"
             assert str(s) == expected_output
 
+    @pytest.mark.parametrize(
+        "value", [[9.4444], [0.49], [10.9999], [9.5444, 9.6], [0.46, 0.78, -9.9999]]
+    )
+    def test_set_option_precision(self, value):
+        # Issue #30122
+        # Precision was incorrectly shown
+
+        with option_context("display.precision", 0):
+
+            df = DataFrame(value)
+            assert str(df) == str(DataFrame(value).round(1))
path: pandas/tests/io/formats/test_format.py
text: @user1:
instead of this can you hard code the expected result (in the parameterization) and check it