Serhiy Storchaka added the comment:

> I replaced get_sys_path()/restore_sys_path() (2 methods) with 
> ModuleAttr.get()+ModuleAttrList.encode_value() / 
> ModuleAttr.restore()+ModuleAttrList.restore_attr() (4 methods).

I need to examine all other methods scattered around just to conclude that they 
are overloaded and aren't used indirectly.

Imagine that you are reading the code first time and need to know only about 
one resource. Three lines in two methods are much simpler then hundreds lines 
scattered in tens of methods.

> I'm not sure that it's a good thing to have dependencies between "resources". 
> I see that Files depends on Cwd, but maybe the Files check can be integrated 
> into Cwd?

I'm not sure that there are only two depended resources. In any case 
deterministic behavior is better. It is very unhappy to to research random test 
failures.

> Ok so the order matters, in this case, I can use a metaclass to use the order 
> of class definition. It will make get_resources() simpler, it will be build 
> directly in the metaclass.

No-no-no. Please don't complicate the code just because you can. This will make 
reading and modifying the code yet harder.

> How do you want to implement that? Currently, a resource has a "get" method 
> which returns a blackbox. It's not easy to display it. There is not standard 
> format.

There is a number of ways.

1. Just write smart general diff reporter as in unittest. It's Python, use 
force^W data reflection!

2. Add third method for resources that need special diff reporting. Use simple 
general diff reporter by default.

3. Split the "sys.path" resource on two simple resources: one test that 
sys.path identity is not changed, other tests it's content.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26643>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to