Repository: pandas-dev/pandas

Issue:
Passing an invalid flavor to read_html prints the wrong error message
#### Code Sample, a copy-pastable example if possible

```python
>>> import pandas as pd
>>> df_list = pd.read_html('https://google.com', flavor='unknown')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/achabot/envs/tmp-b79b7181308bb9c1/lib/python3.7/site-packages/pandas/io/html.py", line 987, in read_html
    displayed_only=displayed_only)
  File "/Users/achabot/envs/tmp-b79b7181308bb9c1/lib/python3.7/site-packages/pandas/io/html.py", line 787, in _parse
    flavor = _validate_flavor(flavor)
  File "/Users/achabot/envs/tmp-b79b7181308bb9c1/lib/python3.7/site-packages/pandas/io/html.py", line 782, in _validate_flavor
    valid=_print_as_set(valid_flavors)))
ValueError: {arg} is not a valid set of flavors, valid flavors are {arg}
```
#### Problem description

The error message should show the `flavor` selected and the valid choices. It's happenning on this line below, and it's a regression from previous versions, which used `%`-formatting and worked properly.

https://github.com/pandas-dev/pandas/blob/de39bfc5e5c6483cb2669773fa10ddc2e32ca111/pandas/io/html.py#L857

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit: None
python: 3.7.0.final.0
python-bits: 64
OS: Darwin
OS-release: 18.2.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.5.0
Cython: None
numpy: 1.15.4
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

</details>



Discussion:
We actually have a test for this, but we don't check the error message.  Oops.

Resolving patch:
diff --git a/pandas/io/html.py b/pandas/io/html.py
--- a/pandas/io/html.py
+++ b/pandas/io/html.py
@@ -854,7 +854,8 @@ def _parser_dispatch(flavor):
 
 
 def _print_as_set(s):
-    return '{{arg}}'.format(arg=', '.join(pprint_thing(el) for el in s))
+    return ('{' + '{arg}'.format(arg=', '.join(
+        pprint_thing(el) for el in s)) + '}')
 
 
 def _validate_flavor(flavor):


Test patch:
diff --git a/pandas/tests/io/test_html.py b/pandas/tests/io/test_html.py
--- a/pandas/tests/io/test_html.py
+++ b/pandas/tests/io/test_html.py
@@ -61,9 +61,12 @@ def test_bs4_version_fails(monkeypatch, datapath):
 
 
 def test_invalid_flavor():
-    url = 'google.com'
-    with pytest.raises(ValueError):
-        read_html(url, 'google', flavor='not a* valid**++ flaver')
+    url = "google.com"
+    flavor = "invalid flavor"
+    msg = r"\{" + flavor + r"\} is not a valid set of flavors"
+
+    with tm.assert_raises_regex(ValueError, msg):
+        read_html(url, "google", flavor=flavor)
 
 
 @td.skip_if_no('bs4')