qpython3h教程_python写的测试框架怎么使用:python qqbot使用教程

python nonebot模块发送文件?

python的模块,pyinstall会自动编译为字节码一起打包。

至于另外的等资源文件,需要自行书写打包配置文件spec。

先用pyinstaller 的 --onefile 选项自动生成一个spec文件,

然后修改这个spec文件案,如要加入图片等附属文件,

要加入到datas中,格式如下:

datas = [("软件包内的相对路径/file.name","/实际路径/file.name","DATA")]

文件列表也可以用Tree生成。Tree("/实际路径/file.name”, prefix = “软件包内的相对路径”)

下面是一个spec文件的例子

a = Analysis(["/tmp/start.py"],

pathex=["/tmp"],

hiddenimports=[],

hookspath=None,

runtime_hooks=None

dict_tree = Tree("/tmp/pic", prefix = "pic")

a.datas = dict_tree

pyz = PYZ(a.pure)

exe = EXE(pyz,

a.scripts,

a.binaries,

a.zipfiles,

a.datas,

name="test",

debug=False,

strip=None,

console=False )

求暗黑followbot 及详细使用方法 443177199@qq.com

follow bot 就是战网己带自己的工具软件

1、双开练KEY候,先开一个D2窗口,称为“D2 S”,建好BB进入游戏,这个BB是准备做为follower的,也就是slave了,再开一个D2窗口,我们称为“D2 M”,建好BB也进入游戏,这个BB是做为MASTER的,也就是做保姆的;

2、然后我们再到d2hackit的文件夹里,运行d2hackit,由于你这个时候双开,d2hackit的进程会有个提示框问你D2 S的进程是否运行d2hackit,你应该点“是”,然后又问你D2 M的进程是否运行d2hackit,这个就要点“否”了(两个提示框的顺序可能会不一样,要看清楚了);

3、切换到“D2 S”的窗口,回车,输入“.follower new”,BB站到ACT1中间那个火坑的7点钟位置;

4、MASTER出城,开TP回城,于是slaver就跟上MASTER了;

5、常用命令就几个“TP”、“wait”、“GO”、“.follower new”

TP---------------------MASTER的命令,让SLAVER进入最靠进的TP,回城比较好用,出城的时候还是手动好,城里的TP多的时候比较容易出错;

wait-------------------MASTER的命令,让SLAVER停止行动;

go----------------------MASTER的命令,让SLAVER继续follower,和wait相对应;

.follower new------slaver的命令,让BB重新followe master。

注意点:在过ACT的时候,slaver都会重新followe下一个出现的BB,所以有时过了ACT后,slaver要运行一下“.follower new”,然后在TP旁边等你的MASTER出城再回城,这样就可以followe到你自己的MASTER了。

集成bind的followbot就是不用自己打命令,只要按一下键盘就自动打命令了

Master_bot_for1.10

点loader到大号

按键"W":wait 停止跟随

按键"G":go 继续跟随

按键"P":npc 和npc说话,主要先去和npc说话

按键"T":tp 进入最后1个释放的回城

Follow_bot_for1.10

点Loader到小号

按键“N”:.follower new 更换新的master

可能很多新人不会用,我写一下

1.要用d2loader才能多开,这是废话了,我把d2loader.exe改成Diablo II.exe,你也可以不改

2.把Diablo II.exe发送快捷方式到桌面,改属性为(注意空格)

"K:\DiabloII\Diablo II.exe" -w -res800 -nonotify -skiptobnet -direct -title 1 -pdir Map

其中 -title 1是运行diablo窗口后窗口标题为“1”,这是做master的,而且重命名为“Diablo II 1”

3.把快捷方式“Diablo II 1”复制一份,重命名为“Diablo II 2”,属性改为

"K:\DiabloII\Diablo II.exe" -w -lq -res800 -nonotify -skiptobnet -direct -title 2

也可以再加个 -ns,就是关声音,但是过关的时候diablo窗口会关闭

4.如此制作“Diablo II 3” “Diablo II 4” “Diablo II 5” “Diablo II 6” “Diablo II 7” “Diablo II 8”快捷方式

5.把Master_bot里面的Loader.exe发送快捷方式到桌面,重命名为Master

6.把Follow_ bot里面的Loader.exe发送快捷方式到桌面,重命名为Follow

7.最好每个人物用不同的帐号

8.启动Diablo II 1窗口,点快捷方式图标Master,可能没什么反应,其实已load成功了

1建游戏进去

9.分别启动2-8窗口,人物在聊天频道,先不要进游戏

10.点快捷方式图标Follow分别load到8-2,即当问“load 8?”时,点“是”。。。,当问“unload 1?”时,点“否”

11.然后2进游戏,1就把2带到安卡拉那里,按“w”;3进游戏,1过来接应,又把3带到安卡拉那里,按“w”;。。。。。如此到8,然后1按“G”,邀请各个bb组队,bb会自动加入

12.开始你的1带7的体验吧,至于用什么人物,你就自由发挥吧

python中qqbot怎么获取登录信息

在命令行输入: **qqbot** ,或直接运行 [qqbot.py][code] : **python qqbot.py** 。启动过程中会自动弹出二维码图片(Linux下需安装有 gvfs

python写的测试框架怎么使用

>pip install -U pytest   # 通过pip安装

>py.test --version        # 查看pytest版本

This is pytest version 2.7.2, imported from C:\Python27\lib\site-packages\pytest.pyc

简单的测试

让我们创一个文件个简单的功能进行测试

#coding=utf-8# 功能def func(x):    return x 1# 测试用例def test_answer():    assert func(3) == 5

切换到测试文件所在的目录,通过“py.test”命令运行测试。

>py.test

执行结果如下图:

===================================================================

在一个测试类中创建多个测试用例:

#coding=utf-8class TestClass:    def test_one(self):

x = "this"

assert "h" in x    def test_two(self):

x = "hello"

assert x == "hi"

运行测试:

>py.test -q test_class.py

-q  为quiet。表示在安静的模式输出报告诉。加不加这个参有什么区别呢? 读者可以对比一下两次输出的日志。其实,就是少了一些pytest的版本信息。

===================================================================

从Python代码中调用pytest

pytest中同样提供了main() 来函数来执行测试用例。

pytest/

├── test_sample.py

├── test_class.py

└── test_main.py

此目录为我们练习的目录,打开test_mian.py

import pytestdef test_main():    assert 5 != 5if __name__ == '__main__':

pytest.main()

直接运行该程序,sublime 中按Ctrl B 运行。结果如下:

============================= test session starts =============================platform win32 -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2rootdir: D:\pyse\pytest, inifile:

collected 4 itemstest_class.py .F

test_main.py F

test_sample.py F================================== FAILURES ===================================_____________________________ TestClass.test_two ______________________________self = def test_two(self):

x = "hello">           assert x == "hi"E           assert 'hello' == 'hi'E             - hello

E             hi

test_class.py:11: AssertionError__________________________________ test_main __________________________________

def test_main():>       assert 5 != 5E    assert 5 != 5test_main.py:4: AssertionError_________________________________ test_answer _________________________________

def test_answer():>       assert func(3) == 5E    assert 4 == 5E      where 4 = func(3)

test_sample.py:9: AssertionError===================== 3 failed, 1 passed in 0.03 seconds ======================[Finished in 0.3s]

从执行结果看到,main() 默认执行了当前文件所在的目录下的所有测试文件。

那么,如果我们只想运行某个测试文件呢?可以向main()中添加参数,就像在cmd命令提示符下面一样:

#coding=utf-8import pytestdef test_main():    assert 5 != 5if __name__ == '__main__':

pytest.main("-q test_main.py")   # 指定测试文件

运行结果:

F================================== FAILURES ===================================__________________________________ test_main __________________________________

def test_main():>       assert 5 != 5E    assert 5 != 5test_main.py:4: AssertionError1 failed in 0.01 seconds

那如果我想运行某个目录下的测试用例呢?指定测试目录即可。

#coding=utf-8import pytestdef test_main():    assert 5 != 5if __name__ == '__main__':

pytest.main("d:/pyse/pytest/")  # 指定测试目录

创建运行测试脚本

有时候我们的测试用例文件分散在不同的层级目录下,通过命令行的方式运行测试显示不太方便,如何编写一个运行所有测试用例的脚本呢? pytest可以自动帮我们生成这样的脚本。

>py.test --genscript=runtests.py

打开生成的测runtests.py文件:

sources = """eNrsve2S3EiSIDa3 jhtnvZ293Ra6SSdCZMUF0AzK1nk9OzM1nV2L4dNznKnm6TxY6dX1XVJVAJV

halMIAkgWVU3O2d6Ar3CPYQeQn/1QjKTf8UnAplZ7O6ZPTNxpiszgQiPCA8PD3cPD/f/449 9/5H

yds/W99M58v6fDqfl1XZzefv/9nbvxuPxxE8Oy r8 jRy2dREq bOt8siqaNo6zKo3hRV 1mRb/h

a1UsuiKPPpRZdFncXNVN3qYRABmN3v/R23 OLbRd/v6/ePOf/tmPflSu1nXTRe1NOxotllnbRq 7

PKlPfwMw0qNR

……"""import sysimport base64import zlibclass DictImporter(object):    def __init__(self, sources):

self.sources = sources    def find_module(self, fullname, path=None):        if fullname == "argparse" and sys.version_info >= (2,7):            # we were generated with = (3, 0):        exec("def do_exec(co, loc): exec(co, loc)\n")        import pickle

sources = sources.encode("ascii") # ensure bytes

sources = pickle.loads(zlib.decompress(base64.decodebytes(sources)))    else:        import cPickle as pickle        exec("def do_exec(co, loc): exec co in loc\n")

sources = pickle.loads(zlib.decompress(base64.decodestring(sources)))

importer = DictImporter(sources)

sys.meta_path.insert(0, importer)

entry = "import pytest; raise SystemExit(pytest.cmdline.main())"

do_exec(entry, locals()) # noqa

好吧!其实, 我也不理解这段代码的含义,但是执行它的可运行测试用例了。

pytest/

├── test_case/

│   ├── test_sample.py

│   ├── test_class.py

│   ├── __init__.py

│   └── test_case2/

│          ├── test_main.py

│          ├── test_time.py

│          └── __init__.py

└── runtests.py

执行runtest.py文件。

>python runtest.py

当然,你也可以打开runtests.py 文件运行它。

===================================================================

* 最后,pytest是如果识别测试用例的呢?它默认使用检查以test_ *.py 或*_test.py命名的文件名,在文件内部查找以test_打头的方法或函数,并执行它们。

pytest还有许多需要讨论的地方,做为这个系列的第一节,先介绍到这里。

版权声明:本站所有文章皆为原创,欢迎转载或转发,请保留网站地址和作者信息。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值