相比其他教程,这篇的重点是pytest这边的设置而不是PyInstaller的,相比PyInstaller 的步骤应该会更简单一些,但是这次的项目并不是很复杂,只是单纯的一个实验仅供参考。
文件结构:
用框画出的部分是执行完第二步才会出现的,单文件会执行这个文件夹下的其中一个文件,多文件会执行这个文件夹下面的所有文件。
1.在pytest项目中配置app.main文件
a.参考官方文档下的Freezing pytest
If you freeze your application using a tool like PyInstaller in order to distribute it to your end-users, it is a good idea to also package your test runner and run your tests using the frozen application. This way packaging errors such as dependencies not being included into the executable can be detected early while also allowing you to send test files to users so they can run them in their machines, which can be useful to obtain more information about a hard to reproduce bug.
如果你想要使用像PyInstaller这样的工具去冻结你的应用程序将它分发给你的客户,将你运行的测试进行打包并且使用冻结程序去运行将会是一个很好的方法。这个方法将会打包错误,例如依赖没有被包括在可执行文件中这个错误将会被提早侦察出来,它同时也