summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-24 20:02:08 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-24 20:02:08 +0100
commit4d6847eb93aa269130ad803fb50be99c4a7508d0 (patch)
tree9ae1cbfa28ca7bd6430b82f5fbca83316ea084ee /tests
parent6c4f5846c8e21d6e48347b7e661edb72ffabb9f1 (diff)
downloadfactory-boy-4d6847eb93aa269130ad803fb50be99c4a7508d0.tar
factory-boy-4d6847eb93aa269130ad803fb50be99c4a7508d0.tar.gz
Default Sequence.type to int (Closes #50).
Diffstat (limited to 'tests')
-rw-r--r--tests/test_containers.py8
-rw-r--r--tests/test_using.py30
2 files changed, 19 insertions, 19 deletions
diff --git a/tests/test_containers.py b/tests/test_containers.py
index 4f70e29..70ed885 100644
--- a/tests/test_containers.py
+++ b/tests/test_containers.py
@@ -253,7 +253,7 @@ class AttributeBuilderTestCase(unittest.TestCase):
self.assertEqual({'one': 2}, ab.build(create=False))
def test_factory_defined_sequence(self):
- seq = declarations.Sequence(lambda n: 'xx' + n)
+ seq = declarations.Sequence(lambda n: 'xx%d' % n)
class FakeFactory(object):
@classmethod
@@ -270,7 +270,7 @@ class AttributeBuilderTestCase(unittest.TestCase):
self.assertEqual({'one': 'xx1'}, ab.build(create=False))
def test_additionnal_sequence(self):
- seq = declarations.Sequence(lambda n: 'xx' + n)
+ seq = declarations.Sequence(lambda n: 'xx%d' % n)
class FakeFactory(object):
@classmethod
@@ -287,8 +287,8 @@ class AttributeBuilderTestCase(unittest.TestCase):
self.assertEqual({'one': 1, 'two': 'xx1'}, ab.build(create=False))
def test_replaced_sequence(self):
- seq = declarations.Sequence(lambda n: 'xx' + n)
- seq2 = declarations.Sequence(lambda n: 'yy' + n)
+ seq = declarations.Sequence(lambda n: 'xx%d' % n)
+ seq2 = declarations.Sequence(lambda n: 'yy%d' % n)
class FakeFactory(object):
@classmethod
diff --git a/tests/test_using.py b/tests/test_using.py
index a0b0db7..2e07621 100644
--- a/tests/test_using.py
+++ b/tests/test_using.py
@@ -315,8 +315,8 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
FACTORY_FOR = TestObject
- one = factory.Sequence(lambda n: 'one' + n)
- two = factory.Sequence(lambda n: 'two' + n)
+ one = factory.Sequence(lambda n: 'one%d' % n)
+ two = factory.Sequence(lambda n: 'two%d' % n)
test_object0 = TestObjectFactory.build()
self.assertEqual(test_object0.one, 'one0')
@@ -334,8 +334,8 @@ class UsingFactoryTestCase(unittest.TestCase):
def _setup_next_sequence(cls):
return 42
- one = factory.Sequence(lambda n: 'one' + n)
- two = factory.Sequence(lambda n: 'two' + n)
+ one = factory.Sequence(lambda n: 'one%d' % n)
+ two = factory.Sequence(lambda n: 'two%d' % n)
test_object0 = TestObjectFactory.build()
self.assertEqual('one42', test_object0.one)
@@ -382,8 +382,8 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
FACTORY_FOR = TestObject
- one = factory.Sequence(lambda n: 'one' + n)
- two = factory.Sequence(lambda n: 'two' + n)
+ one = factory.Sequence(lambda n: 'one%d' % n)
+ two = factory.Sequence(lambda n: 'two%d' % n)
objs = TestObjectFactory.build_batch(20)
@@ -408,8 +408,8 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
FACTORY_FOR = TestObject
- one = factory.LazyAttributeSequence(lambda a, n: 'abc' + n)
- two = factory.LazyAttributeSequence(lambda a, n: a.one + ' xyz' + n)
+ one = factory.LazyAttributeSequence(lambda a, n: 'abc%d' % n)
+ two = factory.LazyAttributeSequence(lambda a, n: a.one + ' xyz%d' % n)
test_object0 = TestObjectFactory.build()
self.assertEqual(test_object0.one, 'abc0')
@@ -472,7 +472,7 @@ class UsingFactoryTestCase(unittest.TestCase):
@factory.sequence
def one(n):
- return 'one' + n
+ return 'one%d' % n
test_object = TestObjectFactory.build()
self.assertEqual(test_object.one, 'one0')
@@ -483,10 +483,10 @@ class UsingFactoryTestCase(unittest.TestCase):
@factory.lazy_attribute_sequence
def one(a, n):
- return 'one' + n
+ return 'one%d' % n
@factory.lazy_attribute_sequence
def two(a, n):
- return a.one + ' two' + n
+ return a.one + ' two%d' % n
test_object = TestObjectFactory.build()
self.assertEqual(test_object.one, 'one0')
@@ -496,8 +496,8 @@ class UsingFactoryTestCase(unittest.TestCase):
class TestObjectFactory(factory.Factory):
FACTORY_FOR = TestObject
- one = factory.Sequence(lambda n: 'one' + n)
- two = factory.Sequence(lambda n: 'two' + n)
+ one = factory.Sequence(lambda n: 'one%d' % n)
+ two = factory.Sequence(lambda n: 'two%d' % n)
test_object0 = TestObjectFactory.build(three='three')
self.assertEqual(test_object0.one, 'one0')
@@ -673,7 +673,7 @@ class UsingFactoryTestCase(unittest.TestCase):
three = factory.Sequence(lambda n: int(n))
objs = TestObjectFactory.stub_batch(20,
- one=factory.Sequence(lambda n: n))
+ one=factory.Sequence(lambda n: str(n)))
self.assertEqual(20, len(objs))
self.assertEqual(20, len(set(objs)))
@@ -862,7 +862,7 @@ class SubFactoryTestCase(unittest.TestCase):
class TestModel2Factory(FakeModelFactory):
FACTORY_FOR = TestModel2
two = factory.SubFactory(TestModelFactory,
- one=factory.Sequence(lambda n: 'x%sx' % n),
+ one=factory.Sequence(lambda n: 'x%dx' % n),
two=factory.LazyAttribute(
lambda o: '%s%s' % (o.one, o.one)))