Created
August 7, 2012 14:31
-
-
Save ashchristopher/3285855 to your computer and use it in GitHub Desktop.
Django Model definition?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ModelTestCase(TestCase): | |
| def test_1(self): | |
| class Foo(object): | |
| arg1 = "str" | |
| arg2 = 1 | |
| class Bar(models.Model): | |
| active = models.BooleanField() | |
| print "Foo_id={0}, Bar_id={1}".format(id(Foo), id(Bar)) | |
| def test_2(self): | |
| class Foo(object): | |
| arg1 = "str" | |
| arg2 = 1 | |
| class Bar(models.Model): | |
| active = models.BooleanField() | |
| print "Foo_id={0}, Bar_id={1}".format(id(Foo), id(Bar)) | |
| Output | |
| ------ | |
| nosetests --verbosity 1 partition_utils -s | |
| Foo_id=206657676, Bar_id=206658540 | |
| .Foo_id=206609932, Bar_id=206658540 | |
| . | |
| ---------------------------------------------------------------------- | |
| Ran 2 tests in 0.002s | |
| *** Notice that Bar has the same id in both tests, so the model isn't being re-defined. *** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment