Author: kmtracey Date: 2009-04-04 14:12:52 -0500 (Sat, 04 Apr 2009) New Revision: 10393
Modified: django/branches/releases/1.0.X/ django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py Log: [1.0.X] Fixed up the tests added for #9779 to run under Python 2.3, which doesn't have set. Merge of the part of [10392] that applies to the 1.0.X branch. Property changes on: django/branches/releases/1.0.X ___________________________________________________________________ Name: svnmerge-integrated - /django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9526,9529,9533-9536,9539-9550,9556-9557,9559-9560,9562-9568,9570-9591,9595-9619,9621-9624,9626-9636,9638-9642,9644-9645,9647-9689,9691-9699,9703-9706,9709-9713,9716-9723,9725-9726,9730-9738,9740-9741,9750-9751,9757-9758,9761-9762,9767-9768,9770-9780,9782-9784,9789-9790,9793-9798,9801-9802,9806-9807,9809-9813,9821-9837,9842-9843,9847-9859,9861,9863-9875,9877-9881,9883-9887,9899-9903,9906-9909,9912,9914,9916-9917,9919-9920,9922-9927,9929,9931-9937,9939,9942-9943,9945-9950,9953-9954,9956-9962,9966-9977,9979-9984,9986-9988,9990-10001,10003-10004,10007,10009-10010,10013-10017,10019-10020,10022-10025,10031,10036-10041,10049-10052,10054-10061,10066-10069,10071-10076,10078-10079,10085-10087,10104,10106,10125-10127,10136,10138-10140,10143,10145-10147,10149-10160,10163-10167,10170,10173,10175-10176,10180,10185,10189,10192-10196,10198-10221,10223-10228,10230-10234,10236-10247,10250-10257,10259-10270,10273-10274,10276-10280,10282-10314,10316,10319-10322,10325,10328-10329,10333-10344,10348-10351,10354-10356,10358-10363,10365-10368,10371-10380,10386-10390 + /django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9247,9249-9262,9264-9277,9279-9298,9301-9302,9305-9331,9333-9343,9345,9347,9350-9352,9355-9396,9399-9462,9466-9469,9471-9488,9491-9526,9529,9533-9536,9539-9550,9556-9557,9559-9560,9562-9568,9570-9591,9595-9619,9621-9624,9626-9636,9638-9642,9644-9645,9647-9689,9691-9699,9703-9706,9709-9713,9716-9723,9725-9726,9730-9738,9740-9741,9750-9751,9757-9758,9761-9762,9767-9768,9770-9780,9782-9784,9789-9790,9793-9798,9801-9802,9806-9807,9809-9813,9821-9837,9842-9843,9847-9859,9861,9863-9875,9877-9881,9883-9887,9899-9903,9906-9909,9912,9914,9916-9917,9919-9920,9922-9927,9929,9931-9937,9939,9942-9943,9945-9950,9953-9954,9956-9962,9966-9977,9979-9984,9986-9988,9990-10001,10003-10004,10007,10009-10010,10013-10017,10019-10020,10022-10025,10031,10036-10041,10049-10052,10054-10061,10066-10069,10071-10076,10078-10079,10085-10087,10104,10106,10125-10127,10136,10138-10140,10143,10145-10147,10149-10160,10163-10167,10170,10173,10175-10176,10180,10185,10189,10192-10196,10198-10221,10223-10228,10230-10234,10236-10247,10250-10257,10259-10270,10273-10274,10276-10280,10282-10314,10316,10319-10322,10325,10328-10329,10333-10344,10348-10351,10354-10356,10358-10363,10365-10368,10371-10380,10386-10392 Modified: django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py =================================================================== --- django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py 2009-04-04 19:03:55 UTC (rev 10392) +++ django/branches/releases/1.0.X/tests/regressiontests/introspection/tests.py 2009-04-04 19:12:52 UTC (rev 10393) @@ -5,13 +5,18 @@ from models import Reporter, Article +try: + set +except NameError: + from sets import Set as set # Python 2.3 fallback + # # The introspection module is optional, so methods tested here might raise # NotImplementedError. This is perfectly acceptable behavior for the backend # in question, but the tests need to handle this without failing. Ideally we'd # skip these tests, but until #4788 is done we'll just ignore them. # -# The easiest way to accomplish this is to decorate every test case with a +# The easiest way to accomplish this is to decorate every test case with a # wrapper that ignores the exception. # # The metaclass is just for fun. @@ -35,14 +40,14 @@ class IntrospectionTests(TestCase): __metaclass__ = IgnoreNotimplementedError - + def test_table_names(self): tl = connection.introspection.table_names() - self.assert_(Reporter._meta.db_table in tl, + self.assert_(Reporter._meta.db_table in tl, "'%s' isn't in table_list()." % Reporter._meta.db_table) - self.assert_(Article._meta.db_table in tl, + self.assert_(Article._meta.db_table in tl, "'%s' isn't in table_list()." % Article._meta.db_table) - + def test_django_table_names(self): cursor = connection.cursor() cursor.execute('CREATE TABLE django_introspection_test_table (id INTEGER);'); @@ -50,26 +55,26 @@ cursor.execute("DROP TABLE django_introspection_test_table;") self.assert_('django_introspection_testcase_table' not in tl, "django_table_names() returned a non-Django table") - + def test_installed_models(self): tables = [Article._meta.db_table, Reporter._meta.db_table] models = connection.introspection.installed_models(tables) self.assertEqual(models, set([Article, Reporter])) - + def test_sequence_list(self): sequences = connection.introspection.sequence_list() expected = {'table': Reporter._meta.db_table, 'column': 'id'} - self.assert_(expected in sequences, + self.assert_(expected in sequences, 'Reporter sequence not found in sequence_list()') - + def test_get_table_description_names(self): cursor = connection.cursor() desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table) self.assertEqual([r[0] for r in desc], [f.column for f in Reporter._meta.fields]) - + def test_get_table_description_types(self): - cursor = connection.cursor() + cursor = connection.cursor() desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table) self.assertEqual([datatype(r[1]) for r in desc], ['IntegerField', 'CharField', 'CharField', 'CharField']) @@ -78,7 +83,7 @@ if settings.DATABASE_ENGINE.startswith('postgresql'): def test_postgresql_real_type(self): cursor = connection.cursor() - cursor.execute("CREATE TABLE django_introspection_real_test_table (number REAL);") + cursor.execute("CREATE TABLE django_introspection_real_test_table (number REAL);") desc = connection.introspection.get_table_description(cursor, 'django_introspection_real_test_table') cursor.execute('DROP TABLE django_introspection_real_test_table;') self.assertEqual(datatype(desc[0][1]), 'FloatField') @@ -86,19 +91,19 @@ def test_get_relations(self): cursor = connection.cursor() relations = connection.introspection.get_relations(cursor, Article._meta.db_table) - + # Older versions of MySQL don't have the chops to report on this stuff, # so just skip it if no relations come back. If they do, though, we # should test that the response is correct. if relations: # That's {field_index: (field_index_other_table, other_table)} self.assertEqual(relations, {3: (0, Reporter._meta.db_table)}) - + def test_get_indexes(self): cursor = connection.cursor() indexes = connection.introspection.get_indexes(cursor, Article._meta.db_table) self.assertEqual(indexes['reporter_id'], {'unique': False, 'primary_key': False}) - + def datatype(dbtype): """Helper to convert a data type into a string.""" dt = connection.introspection.data_types_reverse[dbtype] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---