diff -r 0d54a78861cf Lib/csv.py --- a/Lib/csv.py Mon Jun 15 09:11:14 2015 -0700 +++ b/Lib/csv.py Tue Jun 16 18:05:38 2015 +0200 @@ -13,11 +13,14 @@ from io import StringIO -__all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE", - "Error", "Dialect", "__doc__", "excel", "excel_tab", - "field_size_limit", "reader", "writer", - "register_dialect", "get_dialect", "list_dialects", "Sniffer", - "unregister_dialect", "__version__", "DictReader", "DictWriter" ] + +__all__ = ["QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE", + "Error", "Dialect", "__doc__", "excel", "excel_tab", + "field_size_limit", "reader", "writer", + "register_dialect", "get_dialect", "list_dialects", "Sniffer", + "unregister_dialect", "__version__", "DictReader", "DictWriter", + "unix_dialect"] + class Dialect: """Describe a CSV dialect. @@ -50,6 +53,7 @@ # We do this for compatibility with py2.3 raise Error(str(e)) + class excel(Dialect): """Describe the usual properties of Excel-generated CSV files.""" delimiter = ',' @@ -60,11 +64,13 @@ quoting = QUOTE_MINIMAL register_dialect("excel", excel) + class excel_tab(excel): """Describe the usual properties of Excel-generated TAB-delimited files.""" delimiter = '\t' register_dialect("excel-tab", excel_tab) + class unix_dialect(Dialect): """Describe the usual properties of Unix-generated CSV files.""" delimiter = ',' diff -r 0d54a78861cf Lib/test/test_csv.py --- a/Lib/test/test_csv.py Mon Jun 15 09:11:14 2015 -0700 +++ b/Lib/test/test_csv.py Tue Jun 16 18:05:38 2015 +0200 @@ -1084,5 +1084,21 @@ self.assertEqual(fileobj.read(), expected) +class MiscTestCase(unittest.TestCase): + def test__all__(self): + # QUOTE_* do not provide __module__ attribute. + expected = {'__doc__', '__version__', 'QUOTE_MINIMAL', 'QUOTE_ALL', + 'QUOTE_NONNUMERIC', 'QUOTE_NONE', + } + blacklist = set() + for name in dir(csv): + if name.startswith('_') or name in blacklist: + continue + module_object = getattr(csv, name) + if getattr(module_object, '__module__', None) in ('csv', '_csv'): + expected.add(name) + self.assertEqual(set(csv.__all__), expected) + + if __name__ == '__main__': unittest.main()