还未发布过话题
  • Python API 自动化 at 2018年01月25日

    楼主~按照您所说的两种方法,执行 python manage.py makemigrations 还是报错,请问知道是什么原因吗
    按第一种 方法a. Add db_table an attribute to models.py.
    在 models.py class TestCase 下 class Meta 加了 db_table='PBS_Dynamic_testcase'

    (env2.7) D:\pycharmdjango\WAPI-master>python manage.py makemigrations
    Traceback (most recent call last):
      File "manage.py", line 22, in <module>
        execute_from_command_line(sys.argv)
      File "D:\envs\env2.7\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
        utility.execute()
      File "D:\envs\env2.7\lib\site-packages\django\core\management\__init__.py", line 337, in execute
        django.setup()
      File "D:\envs\env2.7\lib\site-packages\django\__init__.py", line 27, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "D:\envs\env2.7\lib\site-packages\django\apps\registry.py", line 116, in populate
        app_config.ready()
      File "D:\envs\env2.7\lib\site-packages\django\contrib\admin\apps.py", line 23, in ready
        self.module.autodiscover()
      File "D:\envs\env2.7\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover
        autodiscover_modules('admin', register_to=site)
      File "D:\envs\env2.7\lib\site-packages\django\utils\module_loading.py", line 50, in autodiscover_modules
        import_module('%s.%s' % (app_config.name, module_to_search))
      File "D:\Python27\Lib\importlib\__init__.py", line 37, in import_module
        __import__(name)
      File "D:\pycharmdjango\WAPI-master\PBS_Dynamic\admin.py", line 66, in <module>
        class HostListFilter(admin.SimpleListFilter):
      File "D:\pycharmdjango\WAPI-master\PBS_Dynamic\admin.py", line 73, in HostListFilter
        for i in use_host_list:
      File "D:\envs\env2.7\lib\site-packages\django\db\models\query.py", line 250, in __iter__
        self._fetch_all()
      File "D:\envs\env2.7\lib\site-packages\django\db\models\query.py", line 1102, in _fetch_all
        self._result_cache = list(self._iterable_class(self))
      File "D:\envs\env2.7\lib\site-packages\django\db\models\query.py", line 122, in __iter__
        for row in compiler.results_iter():
      File "D:\envs\env2.7\lib\site-packages\django\db\models\sql\compiler.py", line 828, in results_iter
        results = self.execute_sql(MULTI)
      File "D:\envs\env2.7\lib\site-packages\django\db\models\sql\compiler.py", line 876, in execute_sql
        cursor.execute(sql, params)
      File "D:\envs\env2.7\lib\site-packages\django\db\backends\utils.py", line 80, in execute
        return super(CursorDebugWrapper, self).execute(sql, params)
      File "D:\envs\env2.7\lib\site-packages\django\db\backends\utils.py", line 65, in execute
        return self.cursor.execute(sql, params)
      File "D:\envs\env2.7\lib\site-packages\django\db\utils.py", line 94, in __exit__
        six.reraise(dj_exc_type, dj_exc_value, traceback)
      File "D:\envs\env2.7\lib\site-packages\django\db\backends\utils.py", line 65, in execute
        return self.cursor.execute(sql, params)
      File "D:\envs\env2.7\lib\site-packages\django\db\backends\sqlite3\base.py", line 328, in execute
        return Database.Cursor.execute(self, query, params)
    django.db.utils.OperationalError: no such table: PBS_Dynamic_testcase
    
    

    按第二种方法b. Change the table name pbs_dynamic_testcase to PBS_Dynamic_testcase.
    对于这个方法,没太明白是哪种方式
    我试过
    1)搜索整个项目中的 pbs_dynamic_testcase 改成 PBS_Dynamic_testcase,还是报 "no such table: PBS_Dynamic_testcase"
    2)将 model.py 中 class TestCase 改成 class testcase,并将项目中引用的地方也改成 testcase,还是报同样的错
    3)将整个项目中的 PBS_Dynamic_testcase 改成 pbs_dynamic_testcase,也将 class TestCase 改成 class testcase,这回报"no such table: pbs_dynamic_testcase"😭
    4)直接手动建了个表 PBS_Dynamic_testcase,这回执行 makemigrates 不报错了,生成了 initial.py,但执行 migate 依然报上面的错,生无可恋😂

    操作系统是 win7,菜鸟不太懂,还请楼主救火~

  • 请问为啥运行到下面这句就直接跑 teardown() 了?
    adb = new AdbBackend();
    输入下面这些

    Connected to the target VM, address: '127.0.0.1:20405', transport: 'socket'
    [2014-11-20 17-07-48][debug]----------绘制图表----------
    Disconnected from the target VM, address: '127.0.0.1:20405', transport: 'socket'
    [2014-11-20 17-07-48][error]error message:
    com.monkey.android.Monkey.tearDown(Monkey.java:149)
    com.monkey.android.Monkey.main(Monkey.java:50)