On Mon, Mar 9, 2020, at 5:40 PM, Don Smiley wrote:
> In unit testing with multiple configurations, I am having trouble closing out 
> everything to go on to the next iteration. For example, the test creates a 
> class Address. I get the following kind of error:
> 
> ```
> /venv/lib/python3.6/site-packages/SQLAlchemy-1.3.13-py3.6-linux-x86_64.egg/sqlalchemy/ext/declarative/clsregistry.py",
>  line 97, in attempt_get\n % (".".join(path + 
> [key]))\nsqlalchemy.exc.InvalidRequestError: Multiple classes found for path 
> "Address" in the registry of this declarative base. Please use a fully 
> module-qualified path.\n')


that error refers to the declarative base class. If your tests set up new 
mappers against a Base each time,, you should use a new Base for each test run 
that sets up those mappers. otherwise you will get conflicting names like above.




> ```
> 
> My endcycle consists of among other things:
> * drop_all(echo=True)
> * drop database 
>> 
> ```
>  engine = create_engine(config)
>  conn = engine.connect()
>  conn.execute("COMMIT")
>  result = conn.execute(f"DROP DATABASE IF EXISTS {dbname}")
>  result.close() 
>  conn.close()
>  engine.dispose()
> ```
> * orm.session.close_all_sessions()
> * I have even tried del objects that have been created, but that seemed 
> futile and desperate.
> 
> Is there something else that I should be doing here, or in a different order?
> Or, should approach unit testing in a different way?
> 
> I am thinking that I could probably unittest by shelling out each 
> configuration to a separate process, but it seems to me that if I had a 
> better understanding I would not need to do that.
> 
> Any advice is welcome.
> 
> 
> 

> --
>  SQLAlchemy - 
>  The Python SQL Toolkit and Object Relational Mapper
> 
> http://www.sqlalchemy.org/
> 
>  To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
>  --- 
>  You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
>  To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/83a39dbf-2062-416b-9f77-bfea51b90661%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/83a39dbf-2062-416b-9f77-bfea51b90661%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/6bfbee5c-4526-494d-8230-19c941fea410%40www.fastmail.com.

Reply via email to