TST: insert 'match' to bare pytest raises in  pandas/tests/internals/
State: closed

- [x] ref #30999
- [ ] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


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

Comments:
Looks like this is breaking a test:
```
E               AssertionError: Pattern "cannot perform __pow\\_\\_ with this index type: DatetimeArray|cannot perform __mod\\_\\_ with this index type: DatetimeArray|cannot perform __truediv\\_\\_ with this index type: DatetimeArray|cannot perform __mul\\_\\_ with this index type: DatetimeArray|cannot perform __pow\\_\\_ with this index type: TimedeltaArray|ufunc 'multiply' cannot use operands with types dtype\\('<m8\\[ns\\]'\\) and dtype\\('<m8\\[ns\\]'\\)|cannot add DatetimeArray and Timestamp" not found in "ufunc multiply cannot use operands with types dtype('<m8[ns]') and dtype('<m8[ns]')"

```
i think something like this would help identify what needs to be done to make the error messages consistent...


```diff
diff --git a/pandas/tests/internals/test_internals.py b/pandas/tests/internals/test_internals.py
index 3f23486cd..9efc95fdb 100644
--- a/pandas/tests/internals/test_internals.py
+++ b/pandas/tests/internals/test_internals.py
@@ -818,14 +818,11 @@ class TestBlockManager:
         invalid_values = [1, "True", [1, 2, 3], 5.0]
         bm1 = create_mgr("a,b,c: i8-1; d,e,f: i8-2")
 
-        msg = (
-            r'For argument "inplace" expected type bool, received type int.|'
-            r'For argument "inplace" expected type bool, received type str.|'
-            r'For argument "inplace" expected type bool, received type list.|'
-            r'For argument "inplace" expected type bool, received type float.'
-        )
-
         for value in invalid_values:
+            msg = (
+                'For argument "inplace" expected type bool,'
+                f" received type {type(value).__name__}."
+            )
             with pytest.raises(ValueError, match=msg):
                 bm1.replace_list([1], [2], inplace=value)
 
@@ -1238,16 +1235,22 @@ class TestCanHoldElement:
         }
 
         if (op, dtype) in invalid:
-            msg = (
-                r"cannot perform __pow\_\_ with this index type: DatetimeArray|"
-                r"cannot perform __mod\_\_ with this index type: DatetimeArray|"
-                r"cannot perform __truediv\_\_ with this index type: DatetimeArray|"
-                r"cannot perform __mul\_\_ with this index type: DatetimeArray|"
-                r"cannot perform __pow\_\_ with this index type: TimedeltaArray|"
-                "ufunc 'multiply' cannot use operands with types dtype"
-                r"\('<m8\[ns\]'\) and dtype\('<m8\[ns\]'\)|"
-                "cannot add DatetimeArray and Timestamp"
-            )
+            if op is operator.add:
+                msg = f"cannot add DatetimeArray and Timestamp"
+            elif op is operator.mul:
+                msg = (
+                    re.escape(
+                        "ufunc 'multiply' cannot use operands with types"
+                        " dtype('<m8[ns]') and dtype('<m8[ns]')"
+                    )
+                    + "|cannot perform __mul__ with this index type: DatetimeArray"
+                )
+            else:
+                msg = (
+                    f"cannot perform __{op.__name__}__ with this index type:"
+                    r" (DatetimeArray|TimedeltaArray)"
+                )
+
             with pytest.raises(TypeError, match=msg):
                 op(s, e.value)
         else:
```
Hello @MomIsBestFriend! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:



There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2020-01-17 16:00:13 UTC
I have reverted the failing test, I will open a separate PR.
thanks @MomIsBestFriend 

I think we are agreed generally that testing for internal Asserts is not worth here. This is adding a single test for this, which is ok. But in general we don't want to add more (and hopefully refactor the internal error messages).