Repository: pandas-dev/pandas
Pull request: Test case dataframe.groupby incorrect with multiindex and None value
- [✔] closes #32492 
- [✔] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [✔] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.


Problem statement:
dataframe.groupby incorrect with multiindex and None value
#### Minimally reproducible example

```python
# pandas==0.24.2
df = pd.DataFrame(data={
    'A': ['a1','a2',None],
    'B': ['b1','b2','b1'],
    'val': [1,2,3],
})
print(df)
print('\n')

grps = df.groupby(['A', 'B'])
print(grps.get_group(('a2','b1')))

```

#### Problem description
Selecting a group which doesn't appear, I obtain a group which should not exist.

#### Expected Output
KeyError

#### Output of ``pd.show_versions()``

<details>

[paste the output of ``pd.show_versions()`` here below this line]
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 62 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.24.2
pytest: None
pip: 19.0.3
setuptools: 40.8.0
Cython: None
numpy: 1.16.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.4.0
sphinx: 2.0.1
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 3.0.3
openpyxl: None
xlrd: 1.2.0
xlwt: None
xlsxwriter: 1.1.7
lxml.etree: 4.3.3
bs4: None
html5lib: 1.0.1
sqlalchemy: 1.3.8
pymysql: 0.9.3
psycopg2: 2.8.3 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

</details>

Hints from issue discussion:
take
Looks fixed on master. Could use a test

```
In [7]: df = pd.DataFrame(data={
   ...:     'A': ['a1','a2',None],
   ...:     'B': ['b1','b2','b1'],
   ...:     'val': [1,2,3],
   ...: })
   ...: print(df)
   ...: print('\n')
   ...:
   ...: grps = df.groupby(['A', 'B'])
   ...: print(grps.get_group(('a2','b1')))
      A   B  val
0    a1  b1    1
1    a2  b2    2
2  None  b1    3
KeyError: ('a2', 'b1')
```

Commit message: Update test_indexing.py

Patch to review:
diff --git a/pandas/tests/groupby/test_indexing.py b/pandas/tests/groupby/test_indexing.py
index 0caa17f387a94..a2c9be2190af0 100644
--- a/pandas/tests/groupby/test_indexing.py
+++ b/pandas/tests/groupby/test_indexing.py
@@ -314,3 +314,18 @@ def test_groupby_duplicated_columns(func):
         [[1.5, 3.0, 1.5]], columns=["A", "B", "A"], index=pd.Index(["G"], name="C")
     )
     tm.assert_frame_equal(result, expected)
+
+
+def test_dataframe_groupby_incorrect_with_multiindex_make_df_from_data():
+    # GH#32492
+    df = pd.DataFrame(
+        data={
+            "A": ["a1", "a2", None],
+            "B": ["b1", "b2", "b1"],
+            "val": [1, 2, 3],
+        }
+    )
+    grps = df.groupby(by=["A", "B"])
+
+    with pytest.raises(KeyError):
+        grps.get_group(("a2", "b1"))


Code review comments:
diff_hunk: @@ -314,3 +314,18 @@ def test_groupby_duplicated_columns(func):
         [[1.5, 3.0, 1.5]], columns=["A", "B", "A"], index=pd.Index(["G"], name="C")
     )
     tm.assert_frame_equal(result, expected)
+
+
+def test_dataframe_groupby_incorrect_with_multiindex_make_df_from_data():
+    # GH#32492
+    df = pd.DataFrame(
+        data={
+            "A": ["a1", "a2", None],
+            "B": ["b1", "b2", "b1"],
+            "val": [1, 2, 3],
+        }
+    )
+    grps = df.groupby(by=["A", "B"])
+
+    with pytest.raises(KeyError):
path: pandas/tests/groupby/test_indexing.py
text: @user1:
Can you add a match statement? I think pre-commit is complaining about this too

@user1:
Please let the reviewer mark conversations as resolved

I mean: 

``pytest.raises(KeyError, match="String to match"):``