diff options
author | Ondřej Nový <novy@ondrej.org> | 2016-02-14 19:26:09 +0100 |
---|---|---|
committer | Ondřej Nový <novy@ondrej.org> | 2016-02-14 19:26:09 +0100 |
commit | a85231280accdfec8ef9cf67213ff706eb242889 (patch) | |
tree | c84bb817ccf5bae224e473bb15959a4fb97d41ba /tests/cyclic/self_ref.py | |
parent | d92aeedcf27326270cb3dcd8b780566728a489a9 (diff) | |
parent | 41560aa54e83fe539c0a5a1935bcaaf6363a522c (diff) | |
download | factory-boy-a85231280accdfec8ef9cf67213ff706eb242889.tar factory-boy-a85231280accdfec8ef9cf67213ff706eb242889.tar.gz |
Merge tag '2.6.1' into debian/unstable
Release of factory_boy 2.6.1
Diffstat (limited to 'tests/cyclic/self_ref.py')
-rw-r--r-- | tests/cyclic/self_ref.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/cyclic/self_ref.py b/tests/cyclic/self_ref.py new file mode 100644 index 0000000..d98b3ab --- /dev/null +++ b/tests/cyclic/self_ref.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2011-2015 Raphaël Barrois +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +"""Helper to test circular factory dependencies.""" + +import factory + +class TreeElement(object): + def __init__(self, name, parent): + self.parent = parent + self.name = name + + +class TreeElementFactory(factory.Factory): + class Meta: + model = TreeElement + + name = factory.Sequence(lambda n: "tree%s" % n) + parent = factory.SubFactory('tests.cyclic.self_ref.TreeElementFactory') |