python项目中的测试打包

2024-03-28 16:08:06 发布

您现在位置:Python中文网/ 问答频道 /正文

项目结构:

project

  some_api
    __init__.py
    api1.py
    api2.py

  some-folder
    some-helper-module.py

lib
  some-libs

docs
  some-docs

Dockerfile

README.md

各种测试的位置应该是什么

  • 单元测试
  • API的功能测试
  • 使用API-like-hocust进行性能测试

可能的解决方案

project类似,我可以有

test
  unit_tests
    test1.py
    test2.py

  functional_tests
    f_test1.py
    f_test2.py

  perf_tests
   locust-files
     load_test1.py
     load_test2.py
   test-data
     something.csv

Tags: 项目pytestprojectapidocsinitload
2条回答

在我们的团队中,我们通常将单元测试与它们引用的python文件放在一起,并将集成和性能测试放在项目之外,因为它们几乎像黑盒一样对其进行测试:

project

  some_api
    __init__.py
    api1.py
    api1_unit_testing.py
    api2.py
    api2_unit_testing.py

  some-folder
    some-helper-module.py

lib
  some-libs

docs
  some-docs

tests
  profiling_performance.py
  integration_testing.py

Dockerfile

README.md

一般来说,这种结构通常是遵循的,希望能有所帮助。所有类型的测试都应在带有独立子模块的测试模块内进行。有关详细信息,请访问here

├── app_name
        │
        ├── app_name
        │   ├── __init__.py
        │   ├── folder_name
        │   └── etc...
        ├── tests
        │   ├── unit
        │   └── integration
        ├── README.md
        ├── setup.py
        └── requirements.txt

相关问题 更多 >