Repository: pandas-dev/pandas

Issue:
TST: Some tests in indexes/datetimes/test_tools.py don't appear to run
#### Code Sample, a copy-pastable example if possible
https://github.com/pandas-dev/pandas/blob/062f6f118fe4ea439ae255a8ff886a532e20ecdb/pandas/tests/indexes/datetimes/test_tools.py#L28-L30

https://github.com/pandas-dev/pandas/blob/062f6f118fe4ea439ae255a8ff886a532e20ecdb/pandas/tests/indexes/datetimes/test_tools.py#L337-L339

#### Problem description
None of the tests in the classes linked above appear to run.  I noticed this because there's a formatting typo that should have been caught by one of the tests:

https://github.com/pandas-dev/pandas/blob/062f6f118fe4ea439ae255a8ff886a532e20ecdb/pandas/core/tools/datetimes.py#L608

Renaming the classes to `TestTimeConversionFormats` and `TestToDatetimeUnit` makes them run locally for me, and the formatting typo gets caught.

I'd be happy to submit a PR to enable these tests and fix the formatting typo.  Wanted to check here first to make sure that these weren't purposefully disabled, and that I'm not missing something obvious.


Discussion:

Resolving patch:
diff --git a/pandas/core/tools/datetimes.py b/pandas/core/tools/datetimes.py
--- a/pandas/core/tools/datetimes.py
+++ b/pandas/core/tools/datetimes.py
@@ -605,7 +605,7 @@ def f(value):
     if len(excess):
         raise ValueError("extra keys have been passed "
                          "to the datetime assemblage: "
-                         "[{excess}]".format(','.join(excess=excess)))
+                         "[{excess}]".format(excess=','.join(excess)))
 
     def coerce(values):
         # we allow coercion to if errors allows


Test patch:
diff --git a/pandas/tests/indexes/datetimes/test_tools.py b/pandas/tests/indexes/datetimes/test_tools.py
--- a/pandas/tests/indexes/datetimes/test_tools.py
+++ b/pandas/tests/indexes/datetimes/test_tools.py
@@ -25,7 +25,7 @@
                     compat)
 
 
-class TimeConversionFormats(object):
+class TestTimeConversionFormats(object):
 
     def test_to_datetime_format(self):
         values = ['1/1/2000', '1/2/2000', '1/3/2000']
@@ -334,7 +334,7 @@ def test_datetime_invalid_datatype(self):
             pd.to_datetime(pd.to_datetime)
 
 
-class ToDatetimeUnit(object):
+class TestToDatetimeUnit(object):
 
     def test_unit(self):
         # GH 11758
@@ -528,7 +528,10 @@ def test_dataframe(self):
         df2 = DataFrame({'year': [2015, 2016],
                          'month': [2, 20],
                          'day': [4, 5]})
-        with pytest.raises(ValueError):
+
+        msg = ("cannot assemble the datetimes: time data .+ does not "
+               "match format '%Y%m%d' \(match\)")
+        with tm.assert_raises_regex(ValueError, msg):
             to_datetime(df2)
         result = to_datetime(df2, errors='coerce')
         expected = Series([Timestamp('20150204 00:00:00'),
@@ -536,26 +539,31 @@ def test_dataframe(self):
         assert_series_equal(result, expected)
 
         # extra columns
-        with pytest.raises(ValueError):
+        msg = ("extra keys have been passed to the datetime assemblage: "
+               "\[foo\]")
+        with tm.assert_raises_regex(ValueError, msg):
             df2 = df.copy()
             df2['foo'] = 1
             to_datetime(df2)
 
         # not enough
+        msg = ('to assemble mappings requires at least that \[year, month, '
+               'day\] be specified: \[.+\] is missing')
         for c in [['year'],
                   ['year', 'month'],
                   ['year', 'month', 'second'],
                   ['month', 'day'],
                   ['year', 'day', 'second']]:
-            with pytest.raises(ValueError):
+            with tm.assert_raises_regex(ValueError, msg):
                 to_datetime(df[c])
 
         # duplicates
+        msg = 'cannot assemble with duplicate keys'
         df2 = DataFrame({'year': [2015, 2016],
                          'month': [2, 20],
                          'day': [4, 5]})
         df2.columns = ['year', 'year', 'day']
-        with pytest.raises(ValueError):
+        with tm.assert_raises_regex(ValueError, msg):
             to_datetime(df2)
 
         df2 = DataFrame({'year': [2015, 2016],
@@ -563,7 +571,7 @@ def test_dataframe(self):
                          'day': [4, 5],
                          'hour': [4, 5]})
         df2.columns = ['year', 'month', 'day', 'day']
-        with pytest.raises(ValueError):
+        with tm.assert_raises_regex(ValueError, msg):
             to_datetime(df2)
 
     def test_dataframe_dtypes(self):
@@ -594,7 +602,7 @@ def test_dataframe_dtypes(self):
             to_datetime(df)
 
 
-class ToDatetimeMisc(object):
+class TestToDatetimeMisc(object):
 
     def test_index_to_datetime(self):
         idx = Index(['1/1/2000', '1/2/2000', '1/3/2000'])