Python pdb改变变量混乱

时间:2010-12-27 03:07:08

标签: python unit-testing debugging transactions sqlalchemy

在使用SQLAlchemy调试我的Python Web应用程序的unittest期间,超级持久用户对象放下了我的下巴 -

> myapp/views/signup.py(73)signup_view()
-> user = model.User(user_name=user_name, email=email, password=password)
(Pdb) n
(Pdb) user
<pweb.models.User object at 0xbbb20ec>
(Pdb) user = None
(Pdb) user
<pweb.models.User object at 0xbbb20ec>     <!-- !!!??? -->

(Pdb) user2 = model.User(user_name=user_name, email=email, password=password)
(Pdb) user2
<pweb.models.User object at 0xbbb2f0c>
(Pdb) user2 = None
(Pdb) user2
(Pdb) 

在独立的琐碎脚本中无法观察到类似的行为 -

(Pdb) l
  1   if __name__ == '__main__':
  2       user = 1
  3       import pdb; pdb.set_trace()
  4  ->     pass
[EOF]
(Pdb) user
1
(Pdb) user = 2
(Pdb) user
2

第一个例子中的理由应该是什么?它可能与Python unittest (using SQLAlchemy) does not write/update database?后面的交易中间有关吗?

0 个答案:

没有答案