runner = BeautifulReport.report("设备管理", description="设备管理", filename="DeviceManagement.html", report_dir="Test_report") File "D:\learn\Anaconda3\lib\site-packages\BeautifulReport\BeautifulReport.py", line 371, in report self.filename = filename if filename.endswith('.html') else filename + '.html' AttributeError: 'str' object has no attribute 'filename'
时间: 2023-07-07 13:39:44 浏览: 51
根据错误信息,`BeautifulReport.report` 方法中的 `filename` 参数似乎必须是一个对象,而不是一个字符串。请检查你的参数传递方式,确保传递的是一个对象。你可以尝试将 `filename` 参数设置为一个 `Path` 对象,例如:
```python
from pathlib import Path
report_dir = Path("Test_report")
filename = report_dir / "DeviceManagement.html"
runner = BeautifulReport.report("设备管理", description="设备管理", filename=filename, report_dir=report_dir)
```
这里使用 `pathlib` 模块创建了一个路径对象,然后将其作为 `filename` 参数传递给 `report` 方法。
相关问题
runner = BeautifulReport.report("设备管理",filename="DeviceManagement.html", report_dir="Test_report") TypeError: report() missing 1 required positional argument: 'description'
根据错误信息,`BeautifulReport.report` 方法需要一个名为 `description` 的必填参数。你可以在调用 `report` 方法时添加一个描述参数,例如:
```python
runner = BeautifulReport.report("设备管理", description="测试报告描述", filename="DeviceManagement.html", report_dir="Test_report")
```
你需要将 `description` 参数替换为你的测试报告描述。
suite = unittest.TestSuite() suite.addTest(DeviceManagement_testcases) runner = unittest.TextTestRunner() br = BeautifulReport(runner) 这个代码有错误吗
这段代码存在错误,因为在 `suite.addTest()` 中需要传递一个测试用例实例,而不是一个测试用例类。可以将 `DeviceManagement_testcases` 实例化后再传递到 `suite.addTest()` 中,例如:
```
DeviceManagement_testcases_instance = DeviceManagement_testcases()
suite.addTest(DeviceManagement_testcases_instance)
```
另外,这段代码中的 `BeautifulReport` 模块需要导入才能使用,否则会提示 `NameError`。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)