Hi, I was testing and this error came up: FlushError: New instance [EMAIL PROTECTED] with identity key (<class 'test_error.Telephone'>, (6666, 2), None) conflicts with persistent instance [EMAIL PROTECTED]
It wasn't supposed to occur since the setup and teardown methods are quite similar to http://elixir.ematia.de/svn/elixir/trunk/tests/test_order_by.py I reduced the script as much as I could: # -*- coding: utf-8 -*- from elixir import * from sqlalchemy import * class Person(Entity): has_field('name', Unicode(80), nullable = False, unique = True) using_options(tablename = 'Person') has_many('Telephones', of_kind = 'Telephone', inverse = 'responsable') class Telephone(Entity): has_field('number', Numeric(12, 0), primary_key = True) using_options(tablename = 'Telephone') belongs_to('responsable', of_kind = 'Person', inverse = 'Telephones', colname = 'id_person_resp', column_kwargs = dict(primary_key = True)) class Test_Model(object): def setup(self): engine = create_engine('sqlite:///') metadata.connect(engine) #metadata.engine.echo = True create_all() p1 = Person(name = 'André') p2 = Person(name = 'Marcos') Telephone(number = 1234, responsable = p1) Telephone(number = 4321, responsable = p1) Telephone(number = 6666, responsable = p2) objectstore.flush() objectstore.clear() def teardown(self): drop_all() def test_responsable(self): p1 = Person.get_by(name = 'André') t = Telephone.get_by(number = 1234) assert t.responsable is p1 t = Telephone.get_by(number = 4321) assert t.responsable is p1 t = Telephone.get_by(number = 6666) assert not t.responsable is p1 def test_x(self): assert True The nosetests result is as following: $ nosetests test_error.py .E ====================================================================== ERROR: test_error.Test_Model.test_x ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/nose-0.9.0-py2.4.egg/nose/case.py", line 126, in setUp try_run(self.testInstance, names) File "/usr/lib/python2.4/site-packages/nose-0.9.0-py2.4.egg/nose/util.py", line 168, in try_run return func() File "/home/andref/projetos/jeronimo/test_error.py", line 32, in setup objectstore.flush() File "build/bdist.linux-i686/egg/sqlalchemy/orm/session.py", line 294, in flush File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 213, in flush File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 368, in execute File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 535, in execute File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 941, in execute File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 963, in execute_save_steps File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 989, in execute_childtasks File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 941, in execute File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 958, in execute_save_steps File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 946, in save_objects File "build/bdist.linux-i686/egg/sqlalchemy/orm/unitofwork.py", line 523, in _save_objects File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 1054, in save_obj FlushError: New instance [EMAIL PROTECTED] with identity key (<class 'test_error.Telephone'>, (6666, 2), None) conflicts with persistent instance [EMAIL PROTECTED] ---------------------------------------------------------------------- Ran 2 tests in 0.367s FAILED (errors=1) Any help? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLElixir" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlelixir?hl=en -~----------~----~----~----~------~----~------~--~---
