Merge lp:~james-w/django-factory/fix-python2.6-compatibility into lp:django-factory

Proposed by James Westby
Status: Merged
Merged at revision: 60
Proposed branch: lp:~james-w/django-factory/fix-python2.6-compatibility
Merge into: lp:django-factory
Diff against target: 92 lines (+30/-6)
3 files modified
README (+3/-1)
django_factory/testcase.py (+7/-2)
django_project/factory_tests/tests.py (+20/-3)
To merge this branch: bzr merge lp:~james-w/django-factory/fix-python2.6-compatibility
Reviewer Review Type Date Requested Status
James Westby Pending
Review via email: mp+92336@code.launchpad.net

Description of the change

Hi,

I hate this fix, so other ideas are welcome.

Thanks,

James

To post a comment you must log in.
61. By James Westby

Improvements from review. Thanks to jml and achuni.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README'
--- README 2012-02-07 23:08:29 +0000
+++ README 2012-02-09 18:35:20 +0000
@@ -352,7 +352,9 @@
3520.93520.9
353```353```
354354
355355 * Fix `TestCase` compatibility with 2.6. Previously when running under 2.6
356 `testtools.TestCase.__init__` wouldn't be called, leading to lots
357 of problems.
356358
3570.83590.8
358```360```
359361
=== modified file 'django_factory/testcase.py'
--- django_factory/testcase.py 2011-12-16 21:30:48 +0000
+++ django_factory/testcase.py 2012-02-09 18:35:20 +0000
@@ -26,14 +26,19 @@
26 ]26 ]
2727
2828
29class TestCase(DjangoTestCase, TesttoolsTestCase):29# N.B. The order of the superclasses matters here.
30# if Django is first then when running under 2.6
31# TesttoolsTestCase.__init__() won't be called,
32# causing all sorts of havoc.
33
34class TestCase(TesttoolsTestCase, DjangoTestCase):
3035
31 def setUp(self):36 def setUp(self):
32 super(TestCase, self).setUp()37 super(TestCase, self).setUp()
33 self.factory = Factory(test_case=self)38 self.factory = Factory(test_case=self)
3439
3540
36class TransactionTestCase(DjangoTransactionTestCase, TesttoolsTestCase):41class TransactionTestCase(TesttoolsTestCase, DjangoTransactionTestCase):
3742
38 def setUp(self):43 def setUp(self):
39 super(TransactionTestCase, self).setUp()44 super(TransactionTestCase, self).setUp()
4045
=== modified file 'django_project/factory_tests/tests.py'
--- django_project/factory_tests/tests.py 2012-02-07 22:58:29 +0000
+++ django_project/factory_tests/tests.py 2012-02-09 18:35:20 +0000
@@ -21,7 +21,10 @@
21from django.db.models import fields as django_fields21from django.db.models import fields as django_fields
22from django.test import TestCase as DjangoTestCase22from django.test import TestCase as DjangoTestCase
2323
24from testtools import TestCase24from testtools import (
25 ExtendedToOriginalDecorator,
26 TestCase,
27 )
25from testtools.matchers import StartsWith28from testtools.matchers import StartsWith
2629
27from django_factory import generators, testcase30from django_factory import generators, testcase
@@ -569,7 +572,7 @@
569 self.assertRaises(TypeError, factory.generate_value, field)572 self.assertRaises(TypeError, factory.generate_value, field)
570573
571574
572class TestFactory(DjangoTestCase, TestCase):575class TestFactory(TestCase, DjangoTestCase):
573576
574 def test_get_fields_with_no_fields(self):577 def test_get_fields_with_no_fields(self):
575 fields = Factory.get_fields(test_models.ModelWithNoFields)578 fields = Factory.get_fields(test_models.ModelWithNoFields)
@@ -1052,7 +1055,7 @@
10521055
1053 def run_test(self, cls, method_name):1056 def run_test(self, cls, method_name):
1054 test = cls(method_name)1057 test = cls(method_name)
1055 result = TestResult()1058 result = ExtendedToOriginalDecorator(TestResult())
1056 result.startTestRun()1059 result.startTestRun()
1057 test.run(result)1060 test.run(result)
1058 result.stopTestRun()1061 result.stopTestRun()
@@ -1071,3 +1074,17 @@
1071 self.assertIsInstance(self.factory, Factory)1074 self.assertIsInstance(self.factory, Factory)
1072 result = self.run_test(Test, 'test_foo')1075 result = self.run_test(Test, 'test_foo')
1073 self.assert_(result.wasSuccessful(), result.errors or result.failures)1076 self.assert_(result.wasSuccessful(), result.errors or result.failures)
1077
1078 def test_test_case_get_unique_integer(self):
1079 class Test(testcase.TestCase):
1080 def test_foo(self):
1081 self.getUniqueInteger()
1082 result = self.run_test(Test, 'test_foo')
1083 self.assert_(result.wasSuccessful(), result.errors or result.failures)
1084
1085 def test_transaction_test_case_get_unique_integer(self):
1086 class Test(testcase.TransactionTestCase):
1087 def test_foo(self):
1088 self.getUniqueInteger()
1089 result = self.run_test(Test, 'test_foo')
1090 self.assert_(result.wasSuccessful(), result.errors or result.failures)

Subscribers

People subscribed via source and target branches

to all changes: